Jump to content
MFG4Ever

Ambient flyby as a possible script

Recommended Posts

So I'm working on creating a bit of ambience in a mission, and I've got the ambient flyby part down.

But right now, thanks to limited scripting skills, and a fried brain, I'm placing down multiple triggers with this line in it:

ambientFly = [getmarkerpos "mkrStart", getMarkerPos "mkrEnd", 50, "FULL", "B_Heli_Light_01_Armed_F", WEST] call BIS_fnc_ambientFlyBy;

Granted the marker names are different for each trigger, but what I would like to have is a scripted version of this, where it's possible to spawn multiple ambient planes/choppers, insead of having to put down a bunch of triggers and markers.

I'm thinking that a script with a sleep function between the calling of each plane/chopper, should see to it, that the spawned aircraft don't crash into one another.

Now I know there are great scripters in the Arma community, and I'm also guessing this would involve some arrays of some sorts, but is it possible to actually script this, or is it only possible to have multiple ambient aircraft by doing it via multiple triggers?

I have a feeling it is possible, and probably fairly simple to do, but at this moment I can't wrap my head around it somehow. (Maybe to many hours of editing, has finally taken its toll ;))

So I'm hoping someone can/will point me in the right direction.

Share this post


Link to post
Share on other sites

{
_ambientFly = [getmarkerpos (_x select 0), getMarkerPos (_x select 1), (_x select 2), (_x select 3), (_x select 4), (_x select 5)] call BIS_fnc_ambientFlyBy;
sleep (_x select 6);
} foreach [ [color="#FF0000"]["mkrStart", "mkrEnd", 50, "FULL", "B_Heli_Light_01_Armed_F", WEST, 15][/color], [color="#0000FF"]["anotherMkrStart", "anotherMkrEnd", 50, "NORMAL", "O_Heli_Light_02_F", EAST, 30][/color] ];

using foreach.

spawns two flybys.

in the red one there is a 15 second pause until next flyby is spawned.

in the blue one there is spawned a opfor heli at different markers, and a 30 second pause until next.

there is ofcourse no next since i only made 2, but you can add unlimited flybys this way.

else maybe use a variation of while and randomized pause, side, type etc...

_vehicles = [ ["B_Heli_Light_01_Armed_F", WEST] , ["O_Heli_Light_02_F", EAST] ];
_startMarkers = ["start1", "start2"];
_endMarkers = ["end1", "end2"];
while {true} do {
_randomVehicle = _vehicles select (floor random count _vehicles);
_randomStart = _startMarkers select (floor random count _startMarkers);
_randomEnd = _endMarkers select (floor random count _endMarkers);

_ambientFly = [getmarkerpos _randomStart, getMarkerPos _randomEnd, 50, "FULL", (_randomVehicle select 0), (_randomVehicle select 1)] call BIS_fnc_ambientFlyBy;
sleep (random 100);  // random 100 seconds pause.
};

Some ideas to work with.

Share this post


Link to post
Share on other sites

Check post below for newer version

Edited by R3vo

Share this post


Link to post
Share on other sites

I took the chance and overhauled my script a bit, to make executing easier.

 

/*
	Author: Revo

	Description:
	Creates a flyby at a predefined locations.

	Parameter(s):
	0: side   - side of vehicles
	1: string - speed of units "LIMITED" , "NORMAL" , "FULL"
	2: number - altidude of flyby
	3: number - min time
	4: number - average time
	5: number - max time
	7: number - number of iterations
	8: number - flyby distance to player
	
        Example: 
        [west,"NORMAL",100,20,40,70,10,1500] execVM "flyby.sqf";


	Returns:
	-
*/

private ["_poolWest","_poolEast","_poolIndependent","_poolCivilian","_side","_speed","_altitude","_timeMax","_timeMin","_iterations","_distance","_startPos","_endPos"];

_poolWest = ["B_Heli_Transport_03_unarmed_F","B_Heli_Light_01_armed_F","B_Heli_Transport_01_F","B_Heli_Attack_01_F","B_Heli_Light_01_F",
				 "B_Heli_Transport_03_F","B_Plane_CAS_01_F","B_UAV_02_F","B_UAV_02_CAS_F"];

_poolEast = ["O_Heli_Light_02_F","O_Heli_Light_02_unarmed_F","O_Heli_Attack_02_F","O_Heli_Attack_02_black_F","O_Plane_CAS_02_F",
				 "O_UAV_02_F","O_UAV_02_CAS_F","O_Heli_Transport_04_F","O_Heli_Transport_04_ammo_F","O_Heli_Transport_04_bench_F",
				 "O_Heli_Transport_04_box_F","O_Heli_Transport_04_covered_F","O_Heli_Transport_04_fuel_F","O_Heli_Transport_04_medevac_F","O_Heli_Transport_04_repair_F"];

_poolIndependent = ["I_Heli_Transport_02_F","I_Heli_light_03_F","I_Heli_light_03_unarmed_F","I_Plane_Fighter_03_AA_F","I_Plane_Fighter_03_CAS_F"];

_poolCivilian = ["C_Heli_Light_01_civil_F"];

_side	  	= param [0,west];
_speed	  	= param [1,"NORMAL"];
_altitude 	= param [2,100];
_min  	  	= param [3,120];
_middle	  	= param [4,240];
_max  	  	= param [5,480];
_iterations = param [6,1];
_distance 	= param [7,3000];

switch (_side) do 
{
    case west: 
	{ 
		for "_i" from 1 to _iterations do 
		{
			_startPos = player getPos [_distance,selectRandom [90,270]];
			_endPos = player getPos [_distance,selectRandom [180,0]];
			[_startPos,_endPos,_altitude,_speed,selectRandom _poolWest,west] call BIS_fnc_ambientFlyby; 
			random [_min,_middle,_max];   
		};
	};
    case east: 
	{ 
		for "_i" from 1 to _iterations do 
		{
			_startPos = player getPos [_distance,selectRandom [90,270]];
			_endPos = player getPos [_distance,selectRandom [180,0]];
			[_startPos,_endPos,_altitude,_speed,selectRandom _poolEast,east] call BIS_fnc_ambientFlyby; 
			random [_min,_middle,_max];   
		};
	};
    case independent: 
	{
		for "_i" from 1 to _iterations do 
		{
			_startPos = player getPos [_distance,selectRandom [90,270]];
			_endPos = player getPos [_distance,selectRandom [180,0]];
			[_startPos,_endPos,_altitude,_speed,selectRandom _poolIndependent,independent] call BIS_fnc_ambientFlyby; 
			random [_min,_middle,_max];   
		};
	};
	case civilian: 
	{
		for "_i" from 1 to _iterations do 
		{
			_startPos = player getPos [_distance,selectRandom [90,270]];
			_endPos = player getPos [_distance,selectRandom [180,0]];
			[_startPos,_endPos,_altitude,_speed,selectRandom _poolCivilian,civilian] call BIS_fnc_ambientFlyby; 
			random [_min,_middle,_max];   
		};
	};
};

Edited by R3vo

Share this post


Link to post
Share on other sites

Thanks guys!

As always, this great community steps up to the plate :)

Share this post


Link to post
Share on other sites

I've updated my post and added an example on how to execute the script.

Share this post


Link to post
Share on other sites

Awesome.

 

Could I add the CUP mod class names of aircraft into the _poolwest and _pooleast, etc.; so that they would also do flybys?

 

For example the AC130. What exactly would I change to make these low flybys, 50m above ground level?

 

Thank you so much for the help.

 

 

I just tried this, and all the aircraft spawned at one time and exploded and fell to the ground. Ok figured out setting the iterations to 1, only spawns 1 aircraft.

 

Now my only issue is the aircraft spawns and after 5 seconds disappears, no matter what I change in parameters.

 

Also, there is no repeating of the flyby, only 1 aircraft spawns, then nothing.

 

I am looking to simulate multiple aircraft traffic in and around the battlefield. This will apply for ground troops and pilots.

Edited by Jnr4817

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

×