So the other night I loaded my silent hill game's main map for game-guru that I made last year.
I noticed something interesting; the AI was only showing around 10% of the CPU usage but my framerate was in the gutter. There are approximately 30 entities on this exceptionally large map. As I killed them, my FPS increased.
I also noticed the AI was aggroing onto me from very far away. This was.. actually kind of messing up the level because you'd play through areas with maybe 1-2 enemies and gets swarmed, and later areas had no enemies.
I tried playing with the view cone, the view distance, etc. Nothing was working. So I realized that these AI entities are ALWAYS active. They are constantly functioning despite how far away you are.
So here's your simple fix (at least, for zombies).
Open C:\<your game guru base folder ex: program files(x86)\steam\steamapps\common\game-guru>\files\scriptbank\ai_zombiewalk.lua
You'll notice in the main section there is one line of code which effectively initiates the AI subroutines.
Simply surround it with this:
local PlayerDist = GetPlayerDistance(e)
if PlayerDist < 1500 and g_PlayerHealth > 0 then --change 1500 to whatever you want, but I found this to be best for me
<one line of code that's already there goes here>
end
Save it annnnnd done!
I tested this for verification by spraying 50 AI traffic cop zombies on a blank flat map with the base , unmodified AI code. I placed a start marker far away from them. I was at 20-29FPS the entire time.
Once I put my code in and kicked on the level, I was at 60 fps even, until I approached the enemies to the point where they were within that 1500 unit distance check, at which point the FPS progressively dropped until they were all aggroed onto me.
-------------------------------------
What this will allow you to do:
Place groups of 3-8 enemies in isolated pockets which will allow minimal hit to your framerate. You can safely have in at least several dozen of these groups in a level. Basically while you can't have a group of 50 all at once, you can have them separated into pockets of 5 or so that will allow more dynamic fights without impacting performance.
This fix can likely be applied to other AIs as well, though I haven't tested it at this point.
Hope it helps!