Jump to content

Dynamically Start/Stop eye-candy units based on client proximity (Mission CPU Optimization)


Recommended Posts

Posted

Hi,

I've come up with another idea on how to potentially add immersion to my missions, but like usual, I'm worried about CPU resources.

I like having airports and FARPS with activity. (Fuel trucks moving about the place, supply trucks moving in and out, personnel/guards walking around the perimeter, etc).

However I also know that each AI unit that I add, adds to the CPU workload. With all airports in my missions having spawn-points, plus a significant number of additional FARPS on a map wide mission as well - this can add up to many hundreds of AI units active just for a bit of immersion.

One thought I'm playing with and would like some insight/feedback is the ability to tag units as being 'immersive units' and have a timer that does checks on them all and activates them if their is a client within x nm of the area, or otherwise deactivates them so they're not using pathing calculations of the CPU, etc. 

This is where I'm looking for some feedback. I know from past experience that even deactivated units can take up CPU resources. Options I have come up with at the moment are as follows:

 

#1 - Activate & Deactivate

Most simplest option to implement. Would stop the AI pathing calculations from occurring, and allow to continue once someone is in range again - but as I understand it, may not be that effective in saving CPU resources because even deactivated units on late start use CPU resources. (I'm not sure just how much it would reduce CPU usage. Does anyone know)? I'm also not quite sure what functions are available for me to do it this way. 

 

#2 - Despawn when not in use

The idea is to use scripting like simple save and then despawn the units. Reload the units when client is in the area again. The problem with this approach is that as I understand it, pathing can't be saved with these scripts which means the reload will load in static units with no pathing.

 

#3 - Use a template and Spawn in when needed / despawn when not

Use something similar to my new .miz template loader script. This loads in paths so would work, but it would mean that the units restart from their original positions each time. It also means that I would have to design them on a different .miz file to the original - which brings in complications where I could path a unit through a spawn point, etc which I'd like to avoid (as I wouldn't be able to visually see in the ME exactly where my FARP is, etc). 

 

This may end up being more trouble than it's worth - but I just wanted to give it an opportunity by throwing the thought out here and seeing what sort of feedback I'd get and if anyone has some ideas that I haven't considered, or otherwise can see what might or might not work from the ideas I've put forward. 

#1 would be my preferred option as it would be the most simplest to implement - I just have doubts about how much it would really save on CPU given that even non-active units tend to hog resources.

Posted

Oh it certainly helps. I use something like your #3 idea for a bubble script, but its a little more complicated. Basically any group that I want to spawn in like that has their probability set to 0 in the mission editor. This means it doesn't exist at anypoint while the mission runs. The script constantly checks the distance between any unit that can spawn a bubble, depending on the mission that would be aircraft and certain weapons spawning bubbles of enemy units and maybe friendly client aircraft spawning friendly bubbles for ambience. The mission maker can place trigger zones to define groupings and to simplify the checks. Say if you had an SA-5 site with groups of SA-15 or AAA emplacements to defend it you don't need or want those short range groups to spawn in until they'd actually be useful. On top of that the script creates virtual bubbles of averaging the spawn range of bubbles within to further simplify the check. 

https://imgur.com/tQ7u92A

The downsides are that you are consistently checking where each unit is at that can spawn something and the actual act of spawning has its own processing woes. For example on the Grayflag server this script causes MIST to update its own databases anytime groups spawn in, slmod also does the same for its own stats handling, and tacview thinks they are new groups entirely so you might end up with units listed 20 times when its just a Patriot battery that never gets attacked. Likewise the number of groups being spawned in at a given moment can be substantial. Its one of those things where an optimization leads to the mission maker adding more units to counteract said optimization. The missions run "fine" with 16000 units placed in the editor, but only so many are alive at a given moment, yet if more players go more places then the number of units alive expands substantially. 

  • Like 1
  • Thanks 1

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...