From dfb8438cd764e6c7e1b5c0a2148e2ecf25ab11fe Mon Sep 17 00:00:00 2001 From: Fox McCloud Date: Sat, 12 Oct 2019 23:39:57 -0400 Subject: [PATCH] Fixes AI Swarmers Doing Nothing (#46939) About The Pull Request AI swarmers are supposed to go after nearly everything in sight, including turfs, but this behavior is broken; I wouldn't be all surprised if other mobs targeting behavior is also broken. In an attempt to make bees perform better, ListTargets behavior was changed here: #31250 While it does, supposedly, perform better, it also breaks swarmers---andddd I suspect other mobs, as well, as this effectively means anything that's not a mob or an object (primarily turfs). Either case, this reverts ListTargets back to what it originally was, restoring intended behavior. That said, since bees are so problematic, they use the current ListTargets behavior to only search for objects and mobs. fixes: #46938 Changelog cl Fox McCloud fix: Fixes AI swarmers just sitting in their base doing nothing /cl --- code/modules/mob/living/simple_animal/hostile/bees.dm | 10 ++++++++++ .../mob/living/simple_animal/hostile/hostile.dm | 8 ++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/code/modules/mob/living/simple_animal/hostile/bees.dm b/code/modules/mob/living/simple_animal/hostile/bees.dm index dd97f4f8050..38b87eae38c 100644 --- a/code/modules/mob/living/simple_animal/hostile/bees.dm +++ b/code/modules/mob/living/simple_animal/hostile/bees.dm @@ -86,6 +86,16 @@ if(!beehome) . += "This bee is homeless!" +/mob/living/simple_animal/hostile/poison/bees/ListTargets() // Bee processing is expessive, so we override them finding targets here. + if(!search_objects) //In case we want to have purely hostile bees + return ..() + else + . = list() // The following code is only very slightly slower than just returning oview(vision_range, targets_from), but it saves us much more work down the line + var/list/searched_for = oview(vision_range, targets_from) + for(var/obj/A in searched_for) + . += A + for(var/mob/A in searched_for) + . += A /mob/living/simple_animal/hostile/poison/bees/proc/generate_bee_visuals() cut_overlays() diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index ca0a96a8dee..2f1a51cd09d 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -127,7 +127,7 @@ //////////////HOSTILE MOB TARGETTING AND AGGRESSION//////////// -/mob/living/simple_animal/hostile/proc/ListTargets()//Step 1, find out what we can see +/mob/living/simple_animal/hostile/proc/ListTargets() //Step 1, find out what we can see if(!search_objects) . = hearers(vision_range, targets_from) - src //Remove self, so we don't suicide @@ -137,11 +137,7 @@ if(can_see(targets_from, HM, vision_range)) . += HM else - . = list() // The following code is only very slightly slower than just returning oview(vision_range, targets_from), but it saves us much more work down the line, particularly when bees are involved - for (var/obj/A in oview(vision_range, targets_from)) - . += A - for (var/mob/A in oview(vision_range, targets_from)) - . += A + . = oview(vision_range, targets_from) /mob/living/simple_animal/hostile/proc/FindTarget(list/possible_targets, HasTargetsList = 0)//Step 2, filter down possible targets to things we actually care about . = list()