Script for configFile use

ArmA editing, missions, modeling, textures, terrains

Moderators: Lone Wolf, Snake Man

Post Reply
Snake Man
Commander-In-Chief
Posts: 9338
Joined: 2000-07-31 22:01:01
Gaming Interests: ArmA, ArmA 2, Falcon 4.0 and OFP.
Editing Interests: All, I (try) to edit everything.
Location: PMC
Contact:

Script for configFile use

Post by Snake Man » 2009-04-04 22:07:11

I'm not sure what this about really, but I needed to check all VTE aircrafts for createVehicle "compatibility" so I made a script which creates all of them one by one.

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! :)";
That's the script. Its very cool feature to be able to pull information out of config with configFile command.

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?
PMC Tactical Forum New User Registration please read new info here.

PMC since 1984

Editing knowledge, visit PMC Editing Wiki
The leading, most detailed and comprehensive modification made for the Vietnam War - Vietnam: The Experience homepage
View our videos in PMC Youtube channel

PMC Tactical forum Advanced Search is power.

"ALPHA BLACK TO PAPA BEAR. ALL RUSSIANS ARE TOAST. OVER."

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests