Jump to content
naught

AI Caching and Distribution System

Recommended Posts

Hi Naught, When I add your init.sqf code to what I've already got, it's not allowing LEA or UPSMON to run. Could you (or anyone else) take a quick look in the spoiler section and help me with the proper syntax. Thanks a lot.

leaFunction = compile preprocessFileLineNumbers "lea\loadout-init.sqf"; call leaFunction;//line generated by LEA.

[]execVM "eos\OpenMe.sqf";

// Init TPWCAS

//[] execVM "tpwcas\tpwcas_script_init.sqf";

sleep 1;

//Init UPSMON script

call compile preprocessFileLineNumbers "scripts\Init_UPSMON.sqf";

sleep 3;

/*

Title: Unit Caching and Distribution Script

Author: Dylan Plecki (Naught)

Version: 1.0.2.2

Description:

An SQF script designed to dynamically cache and distribute AI units

across machines for maximum performance.

Usage:

None, script is fully autonomous.

Requirements:

Arma 2 OA [1.62]

Arma 3 [any version]

CBA [any version]

License:

Copyright © 2013 Dylan Plecki. All rights reserved.

Except where otherwise noted, this work is licensed under CC BY-NC-ND 4.0,

available for reference at <http://creativecommons.org/licenses/by-nc-nd/4.0/>.

*/

#include "h\oop.h"

/*

Group: Definitons

*/

// Don't change this!

UCD_init = false;

#include "config.sqf"

/*

Group: Macros

*/

#define CHECK_MOD(mod) isClass(configFile >> "CfgMods" >> mod)

/*

Group: Libraries

*/

#include "lib\arrays.sqf"

#include "lib\hashmaps.sqf"

#include "lib\objects.sqf"

#include "lib\caching.sqf"

#include "lib\distribution.sqf"

/*

Group: Initialization Finalization

*/

if (isServer) then {

UCD_serverInit = true;

publicVariable "UCD_serverInit";

};

UCD_init = true;

Share this post


Link to post
Share on other sites
the caching portion can transform a mission with potentially 416 AI (on multiple headless clients of course) to about 32 AI. This is a reduction of over 92%, and since Arma performance scaling is largely non-linear after about 100+ AI on one machine, that could mean huge multiples of performance (think way over 24x greater performance on a previously unplayable mission).

That's all good and well but for a mission with over two thousand ai the choice becomes one of unplayable and unplayable.

Edited by Flens

Share this post


Link to post
Share on other sites
Hi Naught, When I add your init.sqf code to what I've already got, it's not allowing LEA or UPSMON to run. Could you (or anyone else) take a quick look in the spoiler section and help me with the proper syntax. Thanks a lot.

You shouldn't be adding any code to your init.sqf; the only file which needs to be edited is the description.ext.

So your root mission folder should contain a description.ext file and a scripts folder, and the scripts folder should contain the unitCaching folder, which then contains the unitCaching init.sqf file.

Share this post


Link to post
Share on other sites

Hi Naught, nice scripts and seems to work well but I just thought of something...

I see by default caching spawn is tied to the viewDistance but sometimes people run large view distances and their object view distances are usually way lower, isn't tying the spawn distance to the viewDistance none-optimal / pointless if AI are only visible by object distance?

Share this post


Link to post
Share on other sites
Hi Naught, nice scripts and seems to work well but I just thought of something...

I see by default caching spawn is tied to the viewDistance but sometimes people run large view distances and their object view distances are usually way lower, isn't tying the spawn distance to the viewDistance none-optimal / pointless if AI are only visible by object distance?

Yes it may be less-than-optimal in some cases, but since viewDistance is the only BI-provided command to measure these types of client-side values on both Arma 2 and 3, I can't really optimize it too much more.

That's largely why I left it to be configurable for the mission maker, so he or she has the option to trade performance for realism.

---------- Post added at 19:37 ---------- Previous post was at 19:26 ----------

Updated to 1.0.2.4 - v1.0 RC 4

There are a few important fixes in this release, so I'd recommend updating if you can.

This is a full-release, but does not contain a guarantee of any type of support.

Bugs and other issues should have been found and patched through testing, but are still possible in the RC. If you find one, report it back in this thread or on the Github issues page.

This release candidate has been deemed stable enough to be used in production environments. Proceeding v1.0 updates should be sparse, should contain nothing major, and should not be mandatory.

Download Unit Caching and Distribution System v1.0 RC 4.


Changelog

1.0.2.4

  • [FIXED] Crewed vehicles retain their states over caching and distributions.
  • [FIXED] Units now properly retain set positions if specified before caching/distribution.
  • [FIXED] Vehicles are no longer distributed (needless operation).
  • [FIXED] Setting of vehicleVarName should now propagate to all machines.
  • [FIXED] Renamed array manipulation function to match syntax (minor edit).

1.0.2.2

  • [FIXED] AI no longer flee when their group is cached (work-around).
  • [FIXED] Library linkages now correctly handle others' exceptions.
  • [FIXED] 'No entry in CfgMagazines ...' error has been fixed (due to currentMagazine command).
  • [FIXED] Rewrote the caching functions to check for all exceptions at the correct points.

1.0.1.8

  • [FIXED] 1.0.1.7 regression which caused caching checks to spin infinitely.

1.0.1.7

  • [FIXED] Units' volatile shifts to leadership are now accounted for while caching.
  • [NOTE] SSD crashed, proceeding without testing (for now).

1.0.1.6

  • [FIXED] Possible error in config.sqf with wrong types.
  • [FIXED] Enabled CBA caching of static files for release version.

1.0.1.5

  • [NEW] Initial public release.

Share this post


Link to post
Share on other sites

New version frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Does this script work for ALL AI in a mission or just a specific side? Also, could this script theoretically be used to handle civilians that populate towns as players move in/through them and then go away as necessary?

Share this post


Link to post
Share on other sites

Sorry I may have a very obvious question that may be similar to the above from Scorch

Do AI spawn back into the game when AI v AI come into contact and no player around.

Share this post


Link to post
Share on other sites

As someone still getting thier feet wet in all this mission making and scripting, let me pose a question.

Suppose I create a basic mission with some groups made with the editor on some patrol etc.

Suppose that for performance sake (esp. when friends have machines that are older etc) I am using AI Spawn Script with triggers so that until the players are within a reasonable distance from an objective there are no objects existing yet (I think thats how AISS works but maybe it is parsed at load time and the objects exist?).

Now suppose that also I use within the AISS command an additional init that utilizes the behaviour portion of UPSMON.

If I use this script, can I assume correctly that first, all of my editor placed groups will be cached except for the leader, and by default the members will spawn back to the leader when their range is the same or less than my view distance?

Two questions then.

What happens when the view distance is greater than the trigger distance for AISS? Does nothing happen since technically the AISS objects have not been created yet?

And then once they are created (after a loop timeout or something) then this script picks them up, and if they are still within my view distance they remain, else they are cached?

After playing a number of missions, sometimes performance, even on my machine, is terrible. I've taken to making my own because they run so much better for everyone. And I'm on a quest to develop the best coding habits I can. Would this work then in many other missions if I de-pbo them and add this script? (I know thats a broad question, just a generalized answer I guess lol)

Share this post


Link to post
Share on other sites
Does this script work for ALL AI in a mission or just a specific side? Also, could this script theoretically be used to handle civilians that populate towns as players move in/through them and then go away as necessary?

Yes, all it works for all AI in the mission. But you can set it up to only cache a specific type of unit, ie. only units of a certain faction. And it most definitely can be used to cache civilians, also.

Sorry I may have a very obvious question that may be similar to the above from Scorch

Do AI spawn back into the game when AI v AI come into contact and no player around.

No, players must be near in order for the AI to respawn. That's a known issue, and I may be able to fix it in a future update (it's probably next on this script's todo list), but it poses a few issues with analytics that may take a while to resolve (predicting AI contact and such).

As someone still getting thier feet wet in all this mission making and scripting, let me pose a question.

Suppose I create a basic mission with some groups made with the editor on some patrol etc.

Suppose that for performance sake (esp. when friends have machines that are older etc) I am using AI Spawn Script with triggers so that until the players are within a reasonable distance from an objective there are no objects existing yet (I think thats how AISS works but maybe it is parsed at load time and the objects exist?).

Now suppose that also I use within the AISS command an additional init that utilizes the behaviour portion of UPSMON.

If I use this script, can I assume correctly that first, all of my editor placed groups will be cached except for the leader, and by default the members will spawn back to the leader when their range is the same or less than my view distance?

Two questions then.

What happens when the view distance is greater than the trigger distance for AISS? Does nothing happen since technically the AISS objects have not been created yet?

And then once they are created (after a loop timeout or something) then this script picks them up, and if they are still within my view distance they remain, else they are cached?

After playing a number of missions, sometimes performance, even on my machine, is terrible. I've taken to making my own because they run so much better for everyone. And I'm on a quest to develop the best coding habits I can. Would this work then in many other missions if I de-pbo them and add this script? (I know thats a broad question, just a generalized answer I guess lol)

Yes, you are correct with your first assumption on how the system works. And if the AISS script has not yet created the units, then nothing will happen, so technically if the viewDistance was greater than the AISS spawn distance then UCD won't perform any caching unless the players were to move out of combat (or away from the AI), which will then cache the spawned units like normal.

And I've made this script specifically to be as compatible as possible, so that all mission makers can utilize the benefits of caching and headless clients without sophisticated scripting mechanisms which they would have to manipulate on their part. There are only a few things that may break when adding this script, most noticeably scripts which count AI for use in other applications (like mission end scripts).

Share this post


Link to post
Share on other sites

Hi Naught,

First of all thank you for this amazing script, I use it very often in our Missions and the performence is great. But I have a little Problem with the UGVs and UAVs, because after the mission starts I have no access to the UGVs. It is possible to exclude specific units to transfer to the HC? Maybe with a phrase directly in the init? Can you give me an example?

I also have problems with triggers, which are connected with waypoints in the Editor, because they won't be transferd to the HC and it isn't possible to stop units via trigger for example. Do you have any solution for that problem?

Thanks in advance

Edited by Sharp512

Share this post


Link to post
Share on other sites
Getting script errors with the unit caching

http://i.imgur.com/sSnXNZA.png

Unfortunately I cannot reproduce the error, and on the line before the line which causes the error it specifically checks if the variable is nil. The only possible explanation would be a nil group - but I cannot seem to get one. Thank you though for your report, and I'll continue to look into it.

Hey great work!! Will this work well in missions created with DAC?

It should work with any and all scripts, although DAC may create too many AI if caching is enabled and active. Once the AI are respawned in though, I'm thinking that DAC will account for it.

Hi Naught,

First of all thank you for this amazing script, I use it very often in our Missions and the performence is great. But I have a little Problem with the UGVs and UAVs, because after the mission starts I have no access to the UGVs. It is possible to exclude specific units to transfer to the HC? Maybe with a phrase directly in the init? Can you give me an example?

I also have problems with triggers, which are connected with waypoints in the Editor, because they won't be transferd to the HC and it isn't possible to stop units via trigger for example. Do you have any solution for that problem?

Thanks in advance

In the current version (1.0.2.4) there is no way to do this, but I just implemented a method in the Github repository (version 1.0.2.5, untested) if you want to use that. This method will require that you set a variable on each group that you don't want distributed, for example putting this code in the group leader's init field:

(group this) setVariable ["UCD_distributeGroup", false, true];

This should work perfectly for your intention.

Share this post


Link to post
Share on other sites

Naught How to delay your script on the beginning of the mission? When i use ups with min-max option to clone the group, cache will not spawn the cloned groups only the leaders. I need to delay the cache script to work properly.

Share this post


Link to post
Share on other sites
Naught How to delay your script on the beginning of the mission? When i use ups with min-max option to clone the group, cache will not spawn the cloned groups only the leaders. I need to delay the cache script to work properly.

In "unitCaching\lib\caching.sqf", line 190, you may add as many checks to the waitUntil structure as you want. For example, if you want the script to wait until 5 seconds after the mission has started, you can use this:

// waitUntil {!isNull _obj}; // Old code
waitUntil {!(isNull _obj) && {time > 5}};

Share this post


Link to post
Share on other sites

Any chances to get it working with UPSMON out of the box? I don't know how to make it working properly with UPSMON.

Thanks in advance

Share this post


Link to post
Share on other sites

Hello Naught!

I just came across this script because someone is quoting a famous one liner from you about somebody's free work :) I love simple and out of the box because it describes me best! Awesome work! I am interested to get this into our latest MCC 4 and specialy the GAIA (ai) that we have worked on (at mcc). See: http://forums.bistudio.com/showthread.php?150909-MCC-Sandbox-3-Dynamic-mission-creating-tool-for-ArmA-3.

I jsut spend about 5 minutes and the script is indeed actively kicking in. There are quite some things that i need to work out and alter but i see great possiblities with this for large scale battles generated all over map. The biggest issue that i have is the fact that GAIA 'classifies' all groups every cycle and gives them points based on the number of troops and type of troops. (5 guys and a car are more points for the ai system then 1 dude). So i have some things to sort out there, but i gues that makes the fun also.

Another note is (and yes i saw you type already that its not meant that way) that i need it to work for enemy sides also.

I would love to have a TS talk one night, if you hold the time! Gimme a PM if you are up for that.

Edited by spirit6

Share this post


Link to post
Share on other sites
I just came across this script because someone is quoting a famous one liner from you about somebody's free work :)

Haha glad to be of service :) Also good to see the guy I'm referencing has now been banned.

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

×