Jump to content
naught

AI Caching and Distribution System

Recommended Posts

Ok I made a workaround. It has some restrictions, but it works perfect for my situation.

Unit cache function

#define CACHE_UNIT_SPAWN_FNC {if (isServer) then {_this execVM "scripts\uncache.sqf"};} // Should remain small, will be sent to all clients on mission load

Uncache.sqf

_lead = leader group _this;
_code = _lead getVariable ["init",{if (true) exitWith {};}];
_lead spawn _code;

Example init of group leader, it has to be the leader.

this setVariable ["init",{[group _this, getPos _this] call BIS_fnc_taskDefend;}]

Possibly not the most performance friendly, considering the code will be run once for each group member, but it works.

Share this post


Link to post
Share on other sites
Ok I made a workaround. It has some restrictions, but it works perfect for my situation.

Unit cache function

#define CACHE_UNIT_SPAWN_FNC {if (isServer) then {_this execVM "scripts\uncache.sqf"};} // Should remain small, will be sent to all clients on mission load

Uncache.sqf

_lead = leader group _this;
_code = _lead getVariable ["init",{if (true) exitWith {};}];
_lead spawn _code;

Example init of group leader, it has to be the leader.

this setVariable ["init",{[group _this, getPos _this] call BIS_fnc_taskDefend;}]

Possibly not the most performance friendly, considering the code will be run once for each group member, but it works.

would this work if the leader was created via script and the code was placed on the leader via a script rather than in the editor ?

  • Like 1

Share this post


Link to post
Share on other sites

It would, but unless you need different code for the different groups, it might just be better to define your own function as needed.

Share this post


Link to post
Share on other sites
Hi Naught,

When you say 're-run UPSMON on them', is that executing UPSMON on the HC? ie via running your config.sqf:

if (!isServer && hasInterface ) exitWith {};

If feel your script is very close to being able to be dropped into UPSMON. There is just one line of code somewhere that needs proper placement

Many thanks,

Just realized that it's UPSMON's fault, if I remember correct it checks to make sure it's run on the server or else it exits.

So remove anything that would do so, the most common code being "if (!isServer) exitWith {}", or you could just change it to "if (hasInterface && !isServer) exitWith {}".

Share this post


Link to post
Share on other sites

Thanks Naught,

Does you recommendation to change the !isserver statements to hasinterface && !isserver extend to the other scripts in the mission to be compatible with your mod?

The key observation is while the AI transfers to the HC essentially all the units that are spawned in via scripts are 'motionless'. I've been able to transfer certain spawns to the HC via editing the !isserver statements but would be great to use your script for everything.

Many thanks!

Share this post


Link to post
Share on other sites

Hi Naught,

Big thank you for this great script.

It's working perfectly on our own version of AW Invade & Annex by BL1P and me.

Got one suggestion though.

We want to use OPFOR for enemies at the AO and INDEPENDENT for dynamic AI across the island.

Enemies at the AO don't have to be cached but AI across the map should be cached.

I can obviously alter your scripts to have it only cache a specific side, but maybe it's a good idea to be able to disable caching for a specific side through the config file.

Yours,

Fluit

Share this post


Link to post
Share on other sites

Hey,

So from browsing this thread i'm getting a little bit of a mixed message. To make this clear - without Headless Client, UPSMON works perfectly fine without any editing to the config and all that, correct?

Also, I did not see anything in this thread about this, but does Multiplayer work perfectly fine with this script? In past experiences with caching in ArmA MP I've had some weird moments with AI despawning and spawning right in front of the player (Guessing from desync and a delay from spawning and despawning). Flying aircraft also appears to get finicky, as all the units must cache and decache pretty rapidly if the player is in a fast mover. Are all of these gripes absent from this script? If so, I can see this script being a go to option for a quick FPS Boost in larger missions :)

Cheers

Share this post


Link to post
Share on other sites

Hi Naught, we started using your unitcaching for our dedi MP sessions (50+ clients). Great performance improvement!

We noticed that when a air units leaves the active area the unit, a heli in this case, lands and the pilot disembarks. Even though the unit still had waypoints to follow it landed. We used the standard config with only the GLOBAL_SPAWN_DISTANCE set to 1000.

Thanks for a great script!

Share this post


Link to post
Share on other sites

Greetings, we are using this script for about a month now and it works great! One inconvenience we got into was editor init fields. We use only the headless client distribution without caching (disabled in config.sqf), when a unit gets transferred to headless client it's initialization field that was set in the editor doesn't run again. Is there anyway to add that or an easy way to do it some other way?

Share this post


Link to post
Share on other sites

First things firsts. Congratulations on an incredible script, Naught, it is changing our clan's life and the way we play Arma. All our gratitude and support on that.

Now the BUT part!

We recently installed an HC server and we are facing some major complications, here's what happens:

- We edit the mission using the script and the mission load correctly but 1 minute after the mission starts, all the AI units despawns completely and is respawned a few meters away from their initial position, sometimes getting hurt or killed in the process. Way points get broken and the pilots and crew of the vehicles jump out of them and stay put in perfect formation, refusing to jump up again.

- It seems that once this happens the hc is not able to read the init of the units anymore and for instance, de-caching units on a-unit bases (this setVariable ["cacheObject", false, true];) doesn't work anymore.

- We've tried to delay the caching but it didn't work.

We think that it's an issue with the distribution script or the configuration of the hc but we cannot figure our way around this fail. It's when the AI is distributed to the HC that the problems begin.

We use ASR-AI artificial intelligence enhance mod but we tried deactivating it and it does the same trick. We tried to configure the config.sqf of the script in all possible ways and the only way everything works fine is cancelling the distribution or shutting down the HC. It's a shame really because the all purpose of this script is the HC and the distribution of the AI in it.

Any clue on what's happening?

In advance, thank you!

Share this post


Link to post
Share on other sites

Ok this looks great to use. But let me see if I understand this as I am a bit slow this morning. So this script caches any units spawned either in editor or spawn script to leader only until player/s are within distance. So, in reading you can also use AI scripts like UPSMON in addition? This should improve performance greatly, can you change the spawn distance for players or is it set. I will download later and take a more detailed look. Looks like a great thing to use.

Share this post


Link to post
Share on other sites

I am also having some issues using the Code "this setVariable ["cacheObject", false, true]" to restrict certain units from cache or being applied using the cache scripts. Problem i am seeing is i have a attack helo sitting at a base. When i leave the area and cache distance kicks in, the leader and/or gunner of that vehicle gets out the vehicle and stands outside of it. So to call in an attack no longer works. This is in SP.

Example to replicate:

1. Please attack helo (add INIT code)

2. place player unit at same location

3. Teleport out of that area to outside cache area

4. go into camera mode and go back to the base area and view the Heli, you'll see the unit is now outside of the vehicle.

Anyone have any ideas on how to work around this? I am also attempting to do this on Artillery Vehicles.

Thanks

Edited by JCae2798

Share this post


Link to post
Share on other sites

As a first test, I simply started it via debug console:

nul = [] execVM "\scripts\unitCaching\init.sqf";

Shouldn't this already work? I'm in a SP environment. The script resides in [a3\scripts\unitCaching\...]

I place my player unit on the other end of Altis, a group of infantry soldiers on the other end never disappears, or parts of them.

Share this post


Link to post
Share on other sites

Hello. We are building a mission for around 50 guys with all kinds of assets and loads of AI so we are looking for a caching script. This one seems well and simple but my question is ; I've downloaded this and couldnt figure it out if there is an option for separating the uncaching for different assets of ours. What I mean is; I want the AI uncache for my Infantry units lets say at 2kms but for my air assets at 1km. because if the AI always uncaches at a standart distance, 2 pilots flying over the AI will uncache the hundreds of AI for the other 48 players :)

Share this post


Link to post
Share on other sites

Is there a way to show how many units are currently cached using hints?

Share this post


Link to post
Share on other sites

Naught,  Thanks for this script. Literally doubled my server's FPS.

Share this post


Link to post
Share on other sites

Hi,

 

I tried to put the script in my mission, but when launching it, all IA disappear, and not appearing again. I'm alone D:

Share this post


Link to post
Share on other sites
On 3/14/2017 at 2:58 PM, ShiftyFR said:

Hi,

 

I tried to put the script in my mission, but when launching it, all IA disappear, and not appearing again. I'm alone D:

 

Same! Did you manage to find out what the issue was?

Share this post


Link to post
Share on other sites

No :(

 

1 hour ago, SkillerPenguin said:

 

Same! Did you manage to find out what the issue was?

 

Share this post


Link to post
Share on other sites
2 hours ago, SkillerPenguin said:

I just did - set the HC allocation in the config file to false.

 Just tried with it :

#define GLOBAL_SPAWN_DISTANCE 1500 // Meters
#define CACHE_DISTRIBUTE_AI false // Distribute to HC machines, may break scripts such as UPSMON
#define CACHE_MONITOR_DELAY 15 // Seconds
#define CACHE_VEH_TIMEOUT 30 // Seconds
#define CACHE_UNIT_SPAWN_FNC {} // Should remain small, will be sent to all clients on mission load

But still not working

Share this post


Link to post
Share on other sites
21 hours ago, ShiftyFR said:

 Just tried with it :


#define GLOBAL_SPAWN_DISTANCE 1500 // Meters
#define CACHE_DISTRIBUTE_AI false // Distribute to HC machines, may break scripts such as UPSMON
#define CACHE_MONITOR_DELAY 15 // Seconds
#define CACHE_VEH_TIMEOUT 30 // Seconds
#define CACHE_UNIT_SPAWN_FNC {} // Should remain small, will be sent to all clients on mission load

But still not working

 

Try putting 1500 as (1500), normally it should work without parantheses but code is weird, other than that, try completely disconnecting your headless clients. 

 

Also, make sure you didn't accidentally snip a bit of code or config somewhere.

Share this post


Link to post
Share on other sites
4 minutes ago, SkillerPenguin said:

 

Try putting 1500 as (1500), normally it should work without parantheses but code is weird, other than that, try completely disconnecting your headless clients. 

 

Also, make sure you didn't accidentally snip a bit of code or config somewhere.

 

Ok, is it as to work in solo aswell ? Or I have to be on my server ?

Share this post


Link to post
Share on other sites
Just now, ShiftyFR said:

 

Ok, is it as to work in solo aswell ? Or I have to be on my server ?

 

If all is well, it should work in single player. However, you should always test it on multiplayer as well.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×