Jump to content
naught

AI Caching and Distribution System

Recommended Posts

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.

Hey spirit! I'm glad that you like my work :)

So a few things about the current status of this script. Firstly, I'm still not too comfortable with the way that AI are removed from vehicles and then replaced back into them since Arma is very ambiguous about how its AI crewing system works, and I couldn't get the AI to reliably remount into certain vehicles after distribution in Arma 2. Note that this issue is only present when a headless client is connected. This is mostly because Arma 2 is missing the valuable command of assignAsTurret, but I've heard from others that just using moveInTurret or any of the similar commands is enough. So after hours of testing I couldn't get to the same conclusion; no matter what combination of commands I used, some AI either refused to enter their vehicles or got out of the immediately.

You can look at the trouble code if you would like, I haven't done much testing with the issue in Arma 3 since I needed an immediate fix in Arma 2 at the time. The affected code is in "\scripts\unitCaching\lib\caching.sqf", lines #145-183. I assume that the testing needed to ensure compatibility with all situations would take a few hours of which I haven't had recently. Luckily it's a fairly simple component that anyone can look at and understand.

And about the checking for enemy AI for spawning cached units, I just released a new version on the Github repository (version 1.0.3.1) which adds support for detecting both near players and enemy AI. It does add a little bit of processing overhead, but not nearly as much as I anticipated, so it's a very workable solution. Note: it hasn't been tested :P

I wrote this while I was very tired so please excuse any errors or such.

Share this post


Link to post
Share on other sites

Hi Naugh,

So if i use this this, will it auto detect and run all AI from my HC or do i need to change anything in my mission spawns to run via HC ?

Not really looking to use the cached Units so would it still run all from HC?

Many thanks

Share this post


Link to post
Share on other sites
Hi Naugh,

So if i use this this, will it auto detect and run all AI from my HC or do i need to change anything in my mission spawns to run via HC ?

Not really looking to use the cached Units so would it still run all from HC?

Many thanks

Yes, it will automatically transfer all units to the HC upon its connection to the server. Any dynamically created units will also move to the HC when they're spawned.

Share this post


Link to post
Share on other sites

is there anyway to see this working on the HC as i am getting the same fps on my dedi when using and not using HC so need to work out if it is transferring the AI

Share this post


Link to post
Share on other sites
Hey spirit! I'm glad that you like my work :)

So a few things about the current status of this script. Firstly, I'm still not too comfortable with the way that AI are removed from vehicles and then replaced back into them since Arma is very ambiguous about how its AI crewing system works, and I couldn't get the AI to reliably remount into certain vehicles after distribution in Arma 2. Note that this issue is only present when a headless client is connected. This is mostly because Arma 2 is missing the valuable command of assignAsTurret, but I've heard from others that just using moveInTurret or any of the similar commands is enough. So after hours of testing I couldn't get to the same conclusion; no matter what combination of commands I used, some AI either refused to enter their vehicles or got out of the immediately.

You can look at the trouble code if you would like, I haven't done much testing with the issue in Arma 3 since I needed an immediate fix in Arma 2 at the time. The affected code is in "\scripts\unitCaching\lib\caching.sqf", lines #145-183. I assume that the testing needed to ensure compatibility with all situations would take a few hours of which I haven't had recently. Luckily it's a fairly simple component that anyone can look at and understand.

And about the checking for enemy AI for spawning cached units, I just released a new version on the Github repository (version 1.0.3.1) which adds support for detecting both near players and enemy AI. It does add a little bit of processing overhead, but not nearly as much as I anticipated, so it's a very workable solution. Note: it hasn't been tested :P

I wrote this while I was very tired so please excuse any errors or such.

Thanks for your answer there! I will checkout your latest release and get back :)

That is good work man! Had quite some good performance going on with a shitload of units. I am exploring at the moment complete removal of very far units so it becomes a 2 layer caching system.

oz4t.jpg

Edited by spirit6

Share this post


Link to post
Share on other sites

This is awesome. Thanks for sharing this hard work.

I don't know if it's been discussed elsewhere, but is it viable/possible to store the units behaviors? They seem to spawn with the default behavior.

P.S.: currently spawning them with "SAFE", since there won't be player contact immediately, anyway.

Edited by rakowozz

Share this post


Link to post
Share on other sites
Hey spirit! I'm glad that you like my work :)

So a few things about the current status of this script. Firstly, I'm still not too comfortable with the way that AI are removed from vehicles and then replaced back into them since Arma is very ambiguous about how its AI crewing system works, and I couldn't get the AI to reliably remount into certain vehicles after distribution in Arma 2. Note that this issue is only present when a headless client is connected. This is mostly because Arma 2 is missing the valuable command of assignAsTurret, but I've heard from others that just using moveInTurret or any of the similar commands is enough. So after hours of testing I couldn't get to the same conclusion; no matter what combination of commands I used, some AI either refused to enter their vehicles or got out of the immediately.

You can look at the trouble code if you would like, I haven't done much testing with the issue in Arma 3 since I needed an immediate fix in Arma 2 at the time. The affected code is in "\scripts\unitCaching\lib\caching.sqf", lines #145-183. I assume that the testing needed to ensure compatibility with all situations would take a few hours of which I haven't had recently. Luckily it's a fairly simple component that anyone can look at and understand.

And about the checking for enemy AI for spawning cached units, I just released a new version on the Github repository (version 1.0.3.1) which adds support for detecting both near players and enemy AI. It does add a little bit of processing overhead, but not nearly as much as I anticipated, so it's a very workable solution. Note: it hasn't been tested :P

I wrote this while I was very tired so please excuse any errors or such.

I took a futher look into the script and i really would like to make use of it for MCC. I also think that i i might be able to hand over solution for the vehicle issue in the script. Then, for my own use i have a question: Am i allowed to use the script, alter it and integrate in MCC? As i read the current license to use this script does not allow that.

Can you make that clearer? If so, then I start getting time into it :)

Share this post


Link to post
Share on other sites

This is my placeholder post for a full *JAWDROP*. The thoughts of your scope are AMAZING. Can't wait to tinker with the code.

THIS is what I THINK this script does (as I have yet to test):

https://drive.google.com/file/d/0B3VdHnk7BX1BUGtMRmMyRDRza1U/edit?usp=sharing

If one could SETOWNER between worldspaces while retaining FSM, Scripts and Waypoints, you may very solve some AI performance issues in A3.

Edited by zorrobyte

Share this post


Link to post
Share on other sites
This is my placeholder post for a full *JAWDROP*. The thoughts of your scope are AMAZING. Can't wait to tinker with the code.

THIS is what I THINK this script does (as I have yet to test):

https://drive.google.com/file/d/0B3VdHnk7BX1BUGtMRmMyRDRza1U/edit?usp=sharing

If one could SETOWNER between worldspaces while retaining FSM, Scripts and Waypoints, you may very solve some AI performance issues in A3.

Very interesting post! Thanks for sharing!

Share this post


Link to post
Share on other sites

Hello.

I have implemented your AI Caching and Distribution System into a version of AW invade and anex.

It caches the AI scripted for the AO with no problem until it comes to the UnCaching which it then seems to half the amount of AI that where originally there.

I used the ASM server monitor on a version without your AICDS which had aprox AIL - 160 (AI local to server)

when the same mission was ran with the AICDS on it cached them down to approx AIR - 28 (AI remote on HC)

When they un-cached there was only aprox AIR- 88 (AI remote on HC)

Ran that test a few times and each time it seemed to reduce the AO amount of AI by half size groups.

Any help appreciated.

Thanks BL1P.

Edited by BL1P

Share this post


Link to post
Share on other sites

I thought I would give some more info in the hopes of getting a fix :)

Heres how AI are created via the init.sqs

AW_fnc_spawnUnits = {

private ["_randomPos","_spawnGroup","_pos","_x","_armourGroup","_armour","_airGroup","_air","_airType"];
_pos = getMarkerPos (_this select 0);
_enemiesArray = [grpNull];
// squad pat
_x = 0;
for "_x" from 1 to PARAMS_SquadsPatrol do {
	_randomPos = [getMarkerPos currentAO, PARAMS_AOSize] call aw_fnc_randomPos;
	_spawnGroup = [_randomPos, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;
	"O_Soldier_AA_F" createUnit [_randomPos, _spawnGroup];
	[_spawnGroup, getMarkerPos currentAO, PARAMS_AOSize] call aw_fnc_spawn2_randomPatrol;
	[(units _spawnGroup)] call aw_setGroupSkill;

	if(DEBUG) then
	{
		_name = format ["%1%2",name (leader _spawnGroup),_x];
		createMarker [_name,getPos (leader _spawnGroup)];
		_name setMarkerType "o_unknown";
		_name setMarkerText format ["Squad Patrol %1",_x];
		_name setMarkerColor "ColorRed";
		[_spawnGroup,_name] spawn
		{
			private["_group","_marker"];
			_group = _this select 0;
			_marker = _this select 1;

			while{count (units _group) > 0} do
			{
				_marker setMarkerPos (getPos (leader _group));
				sleep 0.1;
			};
			deleteMarker _marker;
		};
	};

	_enemiesArray = _enemiesArray + [_spawnGroup];
};
//--- Defence pat
_x = 0;
for "_x" from 1 to PARAMS_SquadsDefend do {
	_randomPos = [getMarkerPos currentAO, PARAMS_AOSize] call aw_fnc_randomPos;
	_spawnGroup = [_randomPos, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_fnc_spawnGroup;
	"O_Soldier_AA_F" createUnit [_randomPos, _spawnGroup];
	[_spawnGroup, getMarkerPos currentAO,50] call aw_fnc_spawn2_perimeterPatrol;
	[(units _spawnGroup)] call aw_setGroupSkill;

	if(DEBUG) then
	{
		_name = format ["%1%2",name (leader _spawnGroup),_x];
		createMarker [_name,getPos (leader _spawnGroup)];
		_name setMarkerType "o_unknown";
		_name setMarkerText format ["Squad Defend %1",_x];;
		_name setMarkerColor "ColorRed";
		[_spawnGroup,_name] spawn
		{
			private["_group","_marker"];
			_group = _this select 0;
			_marker = _this select 1;

			while{count (units _group) > 0} do
			{
				_marker setMarkerPos (getPos (leader _group));
				sleep 0.1;
			};
			deleteMarker _marker;
		};
	};

	_enemiesArray = _enemiesArray + [_spawnGroup];
};
// teams pat
_x = 0;
for "_x" from 1 to PARAMS_TeamsPatrol do {
	_randomPos = [getMarkerPos currentAO, PARAMS_AOSize] call aw_fnc_randomPos;
	_spawnGroup = [_randomPos, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup;
	/* "O_Soldier_AA_F" createUnit [_randomPos, _spawnGroup];
	[_spawnGroup, getMarkerPos currentAO, (PARAMS_AOSize / 2)] call aw_fnc_spawn2_randomPatrol; */
	[(units _spawnGroup)] call aw_setGroupSkill;

	if(DEBUG) then
	{
		_name = format ["%1%2",name (leader _spawnGroup),_x];
		createMarker [_name,getPos (leader _spawnGroup)];
		_name setMarkerType "o_unknown";
		_name setMarkerText format ["Team Patrol %1",_x];;
		_name setMarkerColor "ColorRed";
		[_spawnGroup,_name] spawn
		{
			private["_group","_marker"];
			_group = _this select 0;
			_marker = _this select 1;

			while{count (units _group) > 0} do
			{
				_marker setMarkerPos (getPos (leader _group));
				sleep 0.1;
			};
			deleteMarker _marker;
		};
	};

	_enemiesArray = _enemiesArray + [_spawnGroup];
};
// cars pat
_x = 0;
for "_x" from 1 to PARAMS_CarsPatrol do {
	_randomPos = [getMarkerPos currentAO, PARAMS_AOSize,6] call aw_fnc_randomPos;
	_spawnGroup = [_randomPos, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Motorized_MTP" >> "OIA_MotInf_Team")] call BIS_fnc_spawnGroup;
	[_spawnGroup, getMarkerPos currentAO, PARAMS_AOSize] call aw_fnc_spawn2_randomPatrol;
	(vehicle (leader _spawnGroup)) spawn aw_fnc_fuelMonitor;
	[(units _spawnGroup)] call aw_setGroupSkill;

	if(DEBUG) then
	{
		_name = format ["%1%2",name (leader _spawnGroup),_x];
		createMarker [_name,getPos (leader _spawnGroup)];
		_name setMarkerType "o_unknown";
		_name setMarkerText format ["Car %1",_x];;
		_name setMarkerColor "ColorRed";
		[_spawnGroup,_name] spawn
		{
			private["_group","_marker"];
			_group = _this select 0;
			_marker = _this select 1;

			while{count (units _group) > 0} do
			{
				_marker setMarkerPos (getPos (leader _group));
				sleep 0.1;
			};
			deleteMarker _marker;
		};
	};

	_enemiesArray = _enemiesArray + [_spawnGroup];
};
// armour pat
for "_x" from 1 to PARAMS_ArmourPatrol do {
	_armourGroup = createGroup east;
	_randomPos = [getMarkerPos currentAO, PARAMS_AOSize,7] call aw_fnc_randomPos;
	if(random 1 < 0.75) then {_armour = "O_MBT_02_cannon_F" createVehicle _randomPos} else {_armour = "O_APC_Tracked_02_AA_F" createVehicle _randomPos};
	waitUntil{!isNull _armour};

	"O_crew_F" createUnit [_randomPos,_armourGroup];
	"O_crew_F" createUnit [_randomPos,_armourGroup];

	((units _armourGroup) select 0) assignAsDriver _armour;
	((units _armourGroup) select 1) assignAsGunner _armour;
	((units _armourGroup) select 0) moveInDriver _armour;
	((units _armourGroup) select 1) moveInGunner _armour;
	[_armourGroup,getMarkerPos currentAO,(PARAMS_AOSize / 2)] call aw_fnc_spawn2_perimeterPatrol;
	_armour spawn aw_fnc_fuelMonitor;
	_enemiesArray = _enemiesArray + [_armourGroup];
	[(units _armourGroup)] call aw_setGroupSkill;

	_armour lock true;
	if(DEBUG) then
	{
		_name = format ["%1%2",name (leader _armourGroup),_x];
		createMarker [_name,getPos (leader _armourGroup)];
		_name setMarkerType "o_unknown";
		_name setMarkerText format ["APC %1",_x];;
		_name setMarkerColor "ColorRed";
		[_armourGroup,_name] spawn
		{
			private["_group","_marker"];
			_group = _this select 0;
			_marker = _this select 1;

			while{count (units _group) > 0} do
			{
				_marker setMarkerPos (getPos (leader _group));
				sleep 0.1;
			};
			deleteMarker _marker;
		};
	};
};

	if((random 10 <= PARAMS_AirPatrol))
		then {
		_airGroup = createGroup east;
		_randomPos = [getMarkerPos currentAO, PARAMS_AOSize] call aw_fnc_randomPos;
		_airType = if(random 1 <= 0.5) then {"O_Heli_Attack_02_F"} else {"O_Heli_Light_02_F"};
		_air = _airType createVehicle [_randomPos select 0,_randomPos select 1,1000];
		waitUntil{!isNull _air};
		_air engineOn true;
		_air lock 3;
		_air setPos [_randomPos select 0,_randomPos select 1,300];

		_air spawn
		{
			private["_x"];
			for [{_x=0},{_x<=200},{_x=_x+1}] do
			{
				_this setVelocity [0,0,0];
				sleep 0.1;
			};
		};

		"O_crew_F" createUnit [_randomPos,_airGroup];
		((units _airGroup) select 0) assignAsDriver _air;
		((units _airGroup) select 0) moveInDriver _air;
		_air removeMagazineTurret ["8Rnd_LG_scalpel",[0]];
		_air removeMagazines "8Rnd_LG_scalpel";

		if(_airType == "O_Heli_Light_02_F") then
		{
			"O_crew_F" createUnit [_randomPos,_airGroup];
			((units _airGroup) select 1) assignAsGunner _air;
			((units _airGroup) select 1) moveInGunner _air;
		};

		[_airGroup,getMarkerPos currentAO,(2 * (PARAMS_AOSize / 3))] call aw_fnc_spawn2_perimeterPatrol;
		_air spawn aw_fnc_fuelMonitor;
		_enemiesArray = _enemiesArray + [_airGroup];
		//[(units _airGroup)] call aw_setGroupSkill;

		if(DEBUG) then
		{
			_name = format ["%1%2",name (leader _airGroup),_x];
			createMarker [_name,getPos (leader _airGroup)];
			_name setMarkerType "o_unknown";
			_name setMarkerText format ["Air %1",_x];;
			_name setMarkerColor "ColorRed";
			[_airGroup,_name] spawn
			{
				private["_group","_marker"];
				_group = _this select 0;
				_marker = _this select 1;

				while{count (units _group) > 0} do
				{
					_marker setMarkerPos (getPos (leader _group));
					sleep 0.1;
				};
				deleteMarker _marker;
			};
		};
	};

	{
		_newGrp = [_x] call AW_fnc_garrisonBuildings;
		if (!isNull _newGrp) then { _enemiesArray = _enemiesArray + [_newGrp]; };
	} forEach (getMarkerPos currentAO nearObjects ["House", 600]);

	_enemiesArray
};

Which is then called later in the init.sqs

//Spawn enemies
_enemiesArray = [currentAO] call AW_fnc_spawnUnits;

This is the error given from the Cache scripts

1:22:23 Error in expression <, []];
_arr = _obj getVariable _var;
};
_arr set [(count _arr), _val];
};

UCD_f>
1:22:23   Error position: <_arr set [(count _arr), _val];
};

UCD_f>
1:22:23   Error Undefined variable in expression: _arr
1:22:23 File mpmissions\__cur_mp.Altis\scripts\unitCaching\lib\arrays.sqf, line 26

Once again thanks for any help

BL1P

Share this post


Link to post
Share on other sites

Good Job Naught! Should you sometime get bored, you could create a script for Object-Caching. Maybe. Someday. Would be nice.

Pit

Share this post


Link to post
Share on other sites

anyone got this working with a headless client and ups ?

If so care to share ?

Share this post


Link to post
Share on other sites

Hey Naught. I really like your script but it seems you are quite hard to reach. For that reason i decided to move away from the script and make my own caching system (which is finished). If you hold interest and time to talk over some caching stuff then i would love to do that. AWesome script man!

Share this post


Link to post
Share on other sites
anyone got this working with a headless client and ups ?

If so care to share ?

What he said

Share this post


Link to post
Share on other sites
Google your way for Headless Client. UPS = UPSMON - Urban Patrol Script

Clear now?

UPS = http://kronzky.info/ups/ NOT UPSMON - Urban Patrol Script thats UPSMON

Getting UPS to work with a headless client is not a problem so we dont need to google it thank you though.

Getting the AI Caching and Distribution System to keep the UPS running on the AI when it transfers them from Server to HC is the problem we where asking for help with and Google hasn't helped with that.

Clear Now ?

Share this post


Link to post
Share on other sites

Hi guys,

Noob question - I'm attempting to implement this script into Escape Chernarus. It uses UPSMON 5.0.9. I note the comments this might not work with it. Upon spawning in the AI do not move which usually patrol and presumably UPSMON to function.

Can I just confirm pls that will be due to the incompatibility or could it be that I have stuffed something else up? Thanks,

Share this post


Link to post
Share on other sites
Hi guys,

Noob question - I'm attempting to implement this script into Escape Chernarus. It uses UPSMON 5.0.9. I note the comments this might not work with it. Upon spawning in the AI do not move which usually patrol and presumably UPSMON to function.

Can I just confirm pls that will be due to the incompatibility or could it be that I have stuffed something else up? Thanks,

I did make a post in this thread about using UPSMON, although not tested it may work: http://forums.bistudio.com/showthread.php?170539-AI-Caching-and-Distribution-System&p=2594890&viewfull=1#post2594890

This is because units are deleted and then respawned in at mission start, so you have to re-run UPSMON on them.

Share this post


Link to post
Share on other sites
I did make a post in this thread about using UPSMON, although not tested it may work: http://forums.bistudio.com/showthread.php?170539-AI-Caching-and-Distribution-System&p=2594890&viewfull=1#post2594890

This is because units are deleted and then respawned in at mission start, so you have to re-run UPSMON on them.

doesn't work with UPSMON or UPS from the tests I ran.

but admittedly I didn't get any help on the questions I asked so maybe someone else got it working ?

Edited by BL1P

Share this post


Link to post
Share on other sites

Thanks guys for the responses and idea.

I'm continuing to tinker around with it an will post any worthwhile findings I make.

Cheers

Share this post


Link to post
Share on other sites
Thanks guys for the responses and idea.

I'm continuing to tinker around with it an will post any worthwhile findings I make.

Cheers

Cool let me know how ya get on I would love to use this package in my mission but i could not get it to work when it moves AI onto Headless It always lost either UPS or UPSMON scripting on the AI.

The package works really well with none scrpted AI but I wanted it for dynamic script created and script ran AI groups on Headless

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,

Share this post


Link to post
Share on other sites

I notice this script isn't so friendly with keeping a unit's init. Is there any work around for this? If I use the guard function on a group that's far away it doesn't work when they spawn in again.

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

×