I found a piece of script code from granQ from his KPCTI which rearms vehicles weapons/magazines based on turret info collected with configFile command. So I implemented that code that it will first check if my aircraft has turrets and if it does, then it creates gunners for all those turrets. I really like this scripting feature in ArmA and thanks for granQ for showing how to use it!
In my mission I only have a gamelogic where the vehicles are spawned, its called "PMC_pos1", then I have radio trigger on repeatedly which sets variable "PMC_proceed" into true.
Here is the script, I'll call it PMC_create_air.sqf
Code: Select all
/*
	Create all VTE aircrafts one by one and place pilot/gunner in them.
*/
private [
	"_respawnpoint", "_grp", "_vcl", "_air", "_myVec", "_PMC_CreateVehicle",
	"_PMC_DeleteVehicles", "_hasTurrets", "_i"
];
// get position from gamelogic
_respawnpoint = getPos PMC_pos1;
// create pilot group
_grp = objNull;
waitUntil
{
	_grp = createGroup (west);
	!(isNull _grp);
};
_vcl = objnull;
/*
whole list of VTE aircrafts.
note that there is one static object amongs them, "VTE_raiderwreck1" !
*/
_air = [
	"VTE_A4", "VTE_A4_R", "VTE_A4_B", "VTE_A4_Napalm", "VTE_b52", "VTE_birddog",
	"VTE_mig19", "VTE_ch34", "VTE_ch34_mc", "VTE_ch34_sog", "VTE_ch34_mg",
	"VTE_ch53", "VTE_ch53_mg", "VTE_uh1", "VTE_uh1a", "VTE_uh1dustoff",
	"VTE_uh1gs", "VTE_uh1guns", "VTE_ch47ca", "VTE_ach47a", "VTE_ch46e",
	"VTE_ch46e_mg", "VTE_RaiderCAS", "VTE_RaiderSAR", "VTE_RaiderSEA",
	"VTE_OV10_ATG", "VTE_OV10_FAC", "VTE_OV10_B", "VTE_OV10_TR",
	"VTE_raiderwreck1", "VTE_ah1g", "VTE_ah1j", "VTE_oh6a", "VTE_oh6arg",
	"VTE_oh6a_unarmed", "VTE_C130", "VTE_MC130", "VTE_ac130", "VTE_F4_GREY_AA",
	"VTE_F4_TAN_AA", "VTE_F4_GREY_AG", "VTE_F4_TAN_AG", "VTE_Intruder",
	"VTE_Intruder_mk82", "VTE_IntruderFire", "VTE_f105", "VTE_f105_r",
	"VTE_MiG17_Snake", "VTE_MiG17_Grey", "VTE_F5SEA", "VTE_F5GREY", "VTE_s56",
	"VTE_s56_mg"
];
_PMC_CreateVehicle =
{
	_myVec = (_air select 0);
	hint format["Creating: %1", _myVec];
	_vcl = _myVec createVehicle _respawnpoint;
	"VTE_acpilot" createUnit [_respawnpoint, _grp, "", 1, "SERGEANT"];
	(units _grp select 0) moveInDriver _vcl;
	// check if have turrets, then creates gunners for them.
	for "_i" from 0 to ((count (configFile >> "CfgVehicles" >> (typeOf _vcl) >> "Turrets")) - 1) do
	{
		"VTE_acpilot" createUnit [_respawnpoint, _grp, "", 1, "CORPORAL"];
		(units _grp select (_i+1)) moveinTurret [_vcl,[_i]];
		player sideChat format["created: %1, guy.", _i];
		addSwitchableUnit (units _grp select _i);
	};
	// remove the just created vehicle from the array.
	_air set [0,"DELETEME"];
	_air = _air - ["DELETEME"];
};
_PMC_DeleteVehicles =
{
	player sideChat format["OK deleting: %1 and unit(s): %2", _myVec, units _grp];
	// delete the plane
	deleteVehicle _vcl;
	// delete group
	{
		deleteVehicle _x;
	} forEach units _grp;
};
/*
	Main code
*/
while {count _air > 0} do
{
	[] call _PMC_CreateVehicle;
	// this would be 1 if true? :)
	_hasTurrets = (count (configFile >> "CfgVehicles" >> (typeOf _vcl) >> "Turrets")) > 0;
	player sideChat format["_hasTurrets: %1",_hasTurrets];
	// wait until player issues radio 0-0-1 command...
	waitUntil
	{
		PMC_proceed;
	};
	PMC_proceed = false;
	[] call _PMC_DeleteVehicles;
	sleep 1;
};
hint "Thank you, thats all folks, aircrafts ran out, sorry! :)";
player sideChat "Thank you, thats all folks, aircrafts ran out, sorry! :)";Any tips how to improve that script, I'd be very glad to hear?
Now... is it possible to pull out all aircraft or helicopter classnames out like this, I mean how do you distinct helo from jet etc?