Product Chat / Simple fix to improve level FPS by up to 50%

Author
Message
Bolt Action Gaming
GameGuru Tool Maker
11
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 13th Dec 2017 15:41
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!


cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 13th Dec 2017 18:16
So are you saying always active = no has stopped working for characters?

Cheers
Bolt Action Gaming
GameGuru Tool Maker
11
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 13th Dec 2017 18:26
Seems that way, at least for active AI objects.
I can say this issue was occurring a year ago as I recalled this same issue happening when I was testing it last year.

I don't know if always active=no is intended to have that specific design to it (of disabling it after a certain distance) but if it is, then the distance is either obscenely large or non functional.
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 13th Dec 2017 18:50
always active = no is supposed to make the scripts on them inactive at distances over 3000 units

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Bolt Action Gaming
GameGuru Tool Maker
11
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 13th Dec 2017 19:27
Thanks. It's not like this stuff is well documented. Last I saw was 6000 units on a steam discussion.

That said, 3000 is a BIG distance to cover, if that's accurate. I'm also 100% positive a vast portion of my exceptionally large map was still aggroing onto me. I'll do some distance checks tonight but all told it appears that either always-active = no may simply be too large a value for most levels to extract any real performance benefit.
Blacknyt46
8
Years of Service
User Offline
Joined: 29th Feb 2016
Location:
Posted: 13th Dec 2017 20:33
Nice! So what do you put in the entities view distance,cone properties? Do I leave it at 0? I hope this does work with other entities also. I have about 20 soldiers in one map. I will be trying this now. Thanks
Jim C
Bolt Action Gaming
GameGuru Tool Maker
11
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 14th Dec 2017 03:27
The view distance simply is the 'engagement distance' so pretty much whatever you want to set for that in terms of their ability to see you.

So for the record I've tested this from one end of the map to the other with 'always active = no' set and it made no difference. I still pulled 20-30 fps.

Once I put my code in, it jumped to 50-60 fps. Of course it chokes once you get close to 50 enemies, but the point is not to put 50 enemies in a clump but to spread them out to avoid the CPU hit while using the player distance check to disable all AI functions until the player is close enough for them to matter.

It made no discernible impact on gameplay. So yeah, to answer the question I don't think always active = no makes any difference for AI module-based entities. My fix still works in this respect.
Bolt Action Gaming
GameGuru Tool Maker
11
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 14th Dec 2017 03:27 Edited at: 14th Dec 2017 03:28


The above is my modified Lua code for ai_zombiewalk.lua; note you can use any distance you want. I like 2000 for my ai test map because it's nice and far away. But I'd recommend 1000-1500 for a live gameplay map.
Solar
7
Years of Service
User Offline
Joined: 11th Apr 2017
Location: South Africa
Posted: 14th Dec 2017 04:41
This is really interesting! Thank you for the info. I will try it out on my zombies!
PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 14th Dec 2017 06:28
Spot on! works great for me , than ksfor the tip. FPS shot up to 60
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, C#, VB, SQL, PL-SQL, JavaScript, HTML, Three.js, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; 12GB.
FPSC to GameGuru Tools: AutoWelder/SegAutoWelder, Entity+Weapon Welder, FPEtoBAT
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 14th Dec 2017 07:20
Sounds like a confirmed bug then - is this on public preview version?

Being able to set the range of activeness when not always active is interesting.

Cheers.

Login to post a reply

Server time is: 2024-11-16 18:53:20
Your offset time is: 2024-11-16 18:53:20