Comrades in Arms Discussion Board

Full Version: FHQ random Air Traffic
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was bothered that there is no ambient air traffic in Arma (with all the ambient cars, animals and people), so I scripted my own. I'll release it here in the hope that it might be useful.

How to use it

The script is called in init.sqf like this:

Code:
[ _minTime, _maxTime, _minAlt, _maxAlt, [_vehicleList], _playerGroup, _spawnDistance] execvm "fhq_randomAirTraffic.sqf";

_minTime and _maxTime define an interval denoting the minimum and maximum time between spawns (randomly chosen). Likewise, _minAlt and _maxAlt give minimum and minimum altitude for the spawns. _vehicleList is a list of planes or choppers; one is picked randomly each time the time interval is hit. _playerGroup is the group around which the planes should be spawned, and _spawnDistance gives the distance to the spawn location.

The script generates a timeout between _minTime and _maxTime, and then creates a randomly chosen vehicle from the list between _minAlt and _maxAlt at _spawnDistance from the player group's leader. The plane will then fly towards the player (+- 45 °) and desspawn when it reaches _spawnDistance from the player again.

Example

Code:
[    
  180, 300,
  100, 400,
  ["L39_TK_EP1", "L39_TK_EP1", "L39_TK_EP1", "Su25_TK_EP1", "Su25_TK_EP1", "Su25_TK_EP1",  "Su25_TK_EP1", "Su25_TK_EP1"],
  FHQ_playerGroup,     
3500] execVM "fhq_randomAirTraffic.sqf";

The example spawns a plane from the list at intervals of 3 to 5 minutes, at an altitude of 100 to 400 meters, 3500 meter away from the leader of FHQ_playerGroup

I gave this a try, all aircraft spawned empty until I checked BIKI on BIS_fnc_spawnVehicle

You either need a civilian unit in mission or a createCenter in the script for this to work.

edit:

Script doesn't like attack helicopters with a pilot and gunner, they just spawn and hover at default altitude, completely ignoring the part of the script that follows:

Code:
        _grp = _vehicleVec select 2;
        _vehicle = _vehicleVec select 0;
        (driver _vehicle) disableAI "TARGET";
        (driver _vehicle) disableAI "AUTOTARGET";
        (driver _vehicle) disableAI "FSM";
        _vehicle flyInHeight _altitude;

         
        _wp = _grp addWaypoint [_targetPos, 1];
        _wp setWaypointType "MOVE";
        _wp setWaypointSpeed "NORMAL";
        _wp setWaypointBehaviour "CARELESS";
        _wp setWaypointCombatMode "BLUE";
        _wp setWaypointStatements ["true", "this call FHQ_RAT_deleteVehicle"]; 

I think the issue is in the first two lines, but I'm not sure.
(03-18-2014, 10:13 AM)Outlawz7 link Wrote: [ -> ]I gave this a try, all aircraft spawned empty until I checked BIKI on BIS_fnc_spawnVehicle

Hmm, strange, it doesn't do that for me, I can perfectly spawn stuff without civilian units on the map. Is that in Arma 2 or Arma 3 ?

edit:

(03-18-2014, 10:13 AM)Outlawz7 link Wrote: [ -> ]Script doesn't like attack helicopters with a pilot and gunner, they just spawn and hover at default altitude, completely ignoring the part of the script that follows:

Code:
        _grp = _vehicleVec select 2;
        _vehicle = _vehicleVec select 0;

I think the issue is in the first two lines, but I'm not sure.

Don't know why this should matter, though. The spawn function returns the group and vehicle in 2 and 0, respectively. So adding a waypoint for the group should do the trick, really

In any case, I'll take a look! Thanks for the feedback
ArmA2
Download corrupted