Jump to content
aduke823

Return array of vehicles that inherit from x.

Recommended Posts

Hello,

 

Here is what I am trying to do step by step...

 

  1. Using configFile command, search "CfgVehicles" >> "Air" .
  2. Pick classes that inherit from "vn_helicopter_base".
  3. Put those classes into an array to pull from randomly.

 

Here is my last attempt to accomplish this...

 

_childClasses = configProperties [configFile >> "CfgVehicles" >> "Air", "inheritsFrom (configFile >> "CfgVehicles" >> "vn_helicopter_base")", true];
_randomType = selectRandom _childClasses;

 

This returns a "type string, expected array" error.

 

I have checked the syntax for all of the involved commands and can't find an error, I'd appreciate any help.

Share this post


Link to post
Share on other sites

Just a couple of things I noticed that aren't necessarily causing the problem...

 

Don't use quotes inside quotes, that is, inside a string expression:

"inheritsFrom (configFile >> "CfgVehicles" >> "vn_helicopter_base")"

Use semi-quotes instead:

"inheritsFrom (configFile >> 'CfgVehicles' >> 'vn_helicopter_base')"

 

According to the Biki entry for configProperties:

Quote

The condition code passed to configProperties should only be used for simple filter expressions and nothing more.

 

Not sure if your condition fits that description, so that might be an issue.

  • Like 3

Share this post


Link to post
Share on other sites

inheritance from (configFile >> "CfgVehicles" >> "vn_helicopter_base") is not what you're aiming. that points at MFD, turrets...

 

You should try something like:

"getText (_x >> 'editorSubcategory') in ['vn_b_helicopters','vn_i_helicopters', 'vn_o_helicopters']" configClasses (configfile >> "CfgVehicles") apply {configName _x}

Of course, you can filter for any combination of  b, i, o for specific side(s).

 

You'll avoid all parachutes which are also "helicopters" in Arma.

  • Like 3

Share this post


Link to post
Share on other sites

Thanks for your replies guys, pierremgi your bit of code did the trick.

 

Here is what I ended up with, I call it ambientBaseHelos.sqf...

Spoiler

 


_hPad = _this select 0;
_hPadPos = position _hPad;
_randomRadialPos = _hPad getPos [5000, random 360];

_typeArray = "getText (_x >> 'editorSubcategory') in ['vn_b_helicopters']" configClasses (configfile >> "CfgVehicles") apply {configName _x};

sleep (random 120);

_randomType = selectRandom _typeArray;

_ambientHelo = [_randomRadialPos, 180, _randomType, BLUFOR] call BIS_fnc_spawnVehicle;
_helo = _ambientHelo select 0;
_driver = driver _helo;
_group = group _driver;

waitUntil {!isNull _group};

_helo addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
_helo enableStamina FALSE;
_helo allowDamage FALSE;
_helo setVehicleReportOwnPosition TRUE;
_helo setVehicleReportRemoteTargets TRUE;
_helo setVehicleReceiveRemoteTargets TRUE;
	
{
	_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
	_x enableStamina FALSE;
	_x allowDamage FALSE;
	_x setVehicleReportOwnPosition TRUE;
	_x setVehicleReportRemoteTargets TRUE;
	_x setVehicleReceiveRemoteTargets TRUE;
}
forEach units _group;
	
_wp1 = _group addWaypoint [_hPadPos, 0];
_wp1 setWaypointType "SCRIPTED";
_wp1 setWaypointScript "A3\functions_f\waypoints\fn_wpLand.sqf";
_wp1 setWaypointStatements ["true", "(vehicle this) engineOn false"];
	
waitUntil {((_helo distance _hPad) < 1000)};
	
_pos = [getPos _hPad select 0, getpos _hPad select 1, (getPos _hPad select 2)+5];
_smokeshell2 = createVehicle ["G_40mm_SmokeRed", _pos, [], 0, "NONE"];
	
sleep 10;
	
waitUntil {unitReady _driver};
	
sleep (random 120);
	
_randomRadialPos = _hPad getPos [5000, random 360];
	
_wp1 = _group addWaypoint [_randomRadialPos, 1];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "FULL";
_wp1 setWaypointStatements ["true", "{deleteVehicle _x} forEach thisList; deleteVehicle (vehicle this)"];

while {true} do 
{
	sleep 120;

	_typeArray = "getText (_x >> 'editorSubcategory') in ['vn_b_helicopters']" configClasses (configfile >> "CfgVehicles") apply {configName _x};

	sleep (random 120);

	_randomType = selectRandom _typeArray;

	_ambientHelo = [_randomRadialPos, 180, _randomType, BLUFOR] call BIS_fnc_spawnVehicle;
	_helo = _ambientHelo select 0;
	_driver = driver _helo;
	_group = group _driver;

	waitUntil {!isNull _group};

	_helo addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
	_helo enableStamina FALSE;
	_helo allowDamage FALSE;
	_helo setVehicleReportOwnPosition TRUE;
	_helo setVehicleReportRemoteTargets TRUE;
	_helo setVehicleReceiveRemoteTargets TRUE;
	
	{
		_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
		_x enableStamina FALSE;
		_x allowDamage FALSE;
		_x setVehicleReportOwnPosition TRUE;
		_x setVehicleReportRemoteTargets TRUE;
		_x setVehicleReceiveRemoteTargets TRUE;
	}
	forEach units _group;
	
	_wp1 = _group addWaypoint [_hPadPos, 0];
	_wp1 setWaypointType "SCRIPTED";
	_wp1 setWaypointScript "A3\functions_f\waypoints\fn_wpLand.sqf";
	_wp1 setWaypointStatements ["true", "(vehicle this) engineOn false"];
	
	waitUntil {((_helo distance _hPad) < 1000)};
	
	_pos = [getPos _hPad select 0, getpos _hPad select 1, (getPos _hPad select 2)+5];
	_smokeshell2 = createVehicle ["G_40mm_SmokeRed", _pos, [], 0, "NONE"];
	
	sleep 10;
	
	waitUntil {unitReady _driver};
	
	sleep (random 120);
	
	_randomRadialPos = _hPad getPos [5000, random 360];
	
	_wp1 = _group addWaypoint [_randomRadialPos, 1];
	_wp1 setWaypointType "MOVE";
	_wp1 setWaypointSpeed "FULL";
	_wp1 setWaypointStatements ["true", "{deleteVehicle _x} forEach thisList; deleteVehicle (vehicle this)"];

};

 

 

 

I execVM the script on a heliPad and it spawns random blufor helicopters to land on the helipad at random intervals, shut off engines, rest for awhile, then take off and get deleted at a distant waypoint. repeat ad infinitum.

 

Really adds to the ambience of 'Nam missions.

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

×