Jump to content
retarded tryhard

How to get an array of classnames of units?

Recommended Posts

Hi!

I'm working on an AI spawning script where it randomly selects from an array of units to create, and I want the array to include all the units from loaded mods instead of just vanilla units. Is there anyway to implement this? Are there any commands that can scan the game file and return such an array?

Share this post


Link to post
Share on other sites
 _getClasses = { 
 
  params ["_faction", "_array"]; 
  _array = []; 
   
  { 
   if ((configName _x) isKindoF "CAManBase") then { 
    _array pushback (configName _x); 
   }; 
  } forEach ("getText (_x >> 'faction') == _faction" configClasses (configfile >> "CfgVehicles")); 
   
  _array 
 };

["blu_F"] call _getClasses;

Change "blu_F" to any faction you want,

 

or for many factions of defined side:

	_getsideFactions = {
	
		params ["_side", "_array"];
		
		_array = [];
		{
			_array pushback	(configName _x);
		} forEach ("getNumber (_x >> 'side') isEqualTo _side" configClasses (configfile >> "CfgFactionClasses"));
		
		_array
	}; 

	_getClasses = {

		params ["_faction", "_array"];
		_array = [];
		
		{
			if ((configName _x) isKindoF "CAManBase") then {
				_array pushback	(configName _x);
			};
		} forEach ("getText (_x >> 'faction') == _faction" configClasses (configfile >> "CfgVehicles"));
		
		_array
	};

	_factions = [1] call _getsideFactions; //0 = east, 1 = west, 2= IND, 3 = civ
	_allunitsofside = [];
	{
				
		_factionunits = [_x] call _getClasses;
		_allunitsofside = _allunitsofside + _factionunits;
	} forEach _factions;	

 

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

×