Jump to content

Mattar_Tharkari

Member
  • Content Count

    961
  • Joined

  • Last visited

  • Medals

Posts posted by Mattar_Tharkari


  1. I use this - seems to work well, it's based on distance not time but you can adapt it with a sleep 300; in there:

    while {true} do {
      {if (!(isNull player) && (count units _x == 0)) then {deleteGroup _x}} foreach allGroups; //deletes empty groups
      {if (!(isNull player) && (_x distance player) >= 250) then {deleteVehicle _x}} forEach allDead; //deletes dead bodies
    };
    


  2. Can't find a suitable example in the wiki for that, where did you get the idea from originally? - _this select n - only works for the execVM params as you say.

    RE - remote execute is part of the original BIS multiplayer scripting framework - general opinion is it's a bit rough and you should use CBA now:

    http://community.bistudio.com/wiki/Multiplayer_framework

    CBA

    https://dev-heaven.net/docs/cba/files/overview-txt.html

    https://dev-heaven.net/projects/cca/wiki/CBA


  3. waitUntil {(_aircrft ammo "MaverickLauncher") == 0};

    or

    if ((_aircrft ammo "CMFlareLauncher") == 0) then {hint "no flares left"};

    The command works for vehicles. However only for the vehicle's gunners' weapons - aka those returned by "weapons vehicle". So you may want to check that before stringing some conditions together with && or and


  4. I have a solution to the last problem - might be bis_fnc_halo, I dunno but the horizontal velocity of the paratroopers increases during the drop and the formation can cover over 1000m with a full C-130. I came up with the idea of using a loop to control the x and y velocity and keep a tighter formation over the dropzone after setPosATL the paratroopers randomly around a marker during the eject, from the players perpective you don't really notice anything. New code shown in red.

    Example mission: https://dl.dropbox.com/u/37698503/HALOexample2.Takistan.zip

    //you need a functions module on the map
    
    private ["_aircraft","_dir","_list"];
    dropNum = dropNum +1;//defined as dropNum = 0; in init.sqf or group leaders init
    
    player sidechat format["Airdrop 0%1 underway!",dropNum];
    
    _aircraft = _this select 0;
     _dir = getDir _aircraft;
       _list = assignedCargo _aircraft;
    
    {
    unassignVehicle (_x); 
      (_x) action ["EJECT", vehicle _x];
        _x spawn bis_fnc_halo;
    
    	sleep 0.1;
    	  _x setDir (_dir - 180);
    	    _x setVelocity [0,-20,-30];
    } foreach _list;
    
    [color="#FF0000"]waitUntil {count (assignedCargo _aircraft) == 0};
    {_x setVelocity [0,0,((velocity _x) select 2)];
     _x SetPosATL [(getMarkerPos "dz1" select 0)+(floor (random 100)),(getMarkerPos "dz1" select 1)+(floor (random 100)),getPosATL _x select 2];[/color]
    //you need a "dz1" marker to mark your dropzone, AI will land in a 100m radius aroud the marker, you can make this value smaller for smaller groups.
    [color="#FF0000"]    } foreach _list;
    
    while {true} do {
    {_x setVelocity [0,0,(velocity _x select 2)];} foreach _list;//loop stops any horizontal movement so they fall straight down
     sleep 0.1;
       if ((player in _list && (getPosATL (_list select 0) select 2) <= 200)) exitWith {hint "Pull Ripcord! Open chute!";};//stops loop once first AI gets to 200m
         if ((!(player in _list) && (getPosATL (_list select 0) select 2) <= 200))  exitWith {};
    };[/color]


  5. Example mission:

    https://dl.dropbox.com/u/37698503/HALOexample.Takistan.zip

    put this in the aircraft waypoint - aircraft must be at 1000m height or so - I don't think triggers are ideal for this imho.

    nul = [vehicle this] execVM "drop.sqf";

    drop.sqf

    //you need a functions module on the map
    dropNum = dropNum +1;//defined as dropNum = 0; in init.sqf or group leaders init
    
    player sidechat format["Airdrop 0%1 underway!",dropNum];
    
    _aircraft = _this select 0;
     _dir = getDir _aircraft;
       _list = assignedCargo _aircraft;
    
    {
    unassignVehicle (_x); 
      (_x) action ["EJECT", vehicle _x];
        _x spawn bis_fnc_halo;
    
    	sleep 0.3;
    	  _x setDir (_dir - 180);
    	    _x setVelocity [0,10,-20];
    } foreach _list;
    

    Squad will land in the grid square where they eject - precise landing solved below - post #5


  6. _evachelopilot - what is that exactly - vehicle or AI - show us where that comes from, flyinheight will probably not work called on an AI pilot.

    _evachelopilot flyinheight 0; - that doesn't make aircraft land.

    All aircraft land into the wind - lookup the setWind command and make sure the heli is flying into the wind on landing or you get odd effects like hovering into the LZ backwards etc. Not tested it but looking at the command for the first time after a few years I wonder if:

     setWind [0,0, false]; 

    will temporarily set the wind to nothing and eliminate some of the odd landing antics?

    If you want an empty heli to land try http://community.bistudio.com/wiki/land

    Otherwise it's best to order nearby units to get in or passengers to get out eg:

    {_x assignAsCargo heliName; [_x] orderGetIn true;} forEach units groupName;

    or in the helicopter waypoint init to make any passengers get out:

    {unassignVehicle _x; [_x] orderGetIn false;} foreach assignedCargo (vehicle this);


  7. edit: changed it - made it simpler - if you have a helicopter flying in a wide circle over the spawn point it will pick up and drop off a new team everytime all the units in the group die.

    example mission, shoot all the units dropped off from the heli and more will get inserted into the LZ (heli is set to 'allowDammage false' - might need to spawn a new heli everytime for this to look realistic:

    https://dl.dropbox.com/u/37698503/RespawnCycle.Takistan.zip

    respwn.sqf

    //you need a functions module on the map; infantry leaders init:
    //nul = [group this,heliName] execVM "respwn.sqf";
    
    private ["_grpRspwn","_ldr","_grp","_cab"];
    waitUntil {!isNil "bis_fnc_init"};
    _grp = _this select 0;
     _cab = _this select 1;
    
    waitUntil {count units _grp  == 0};
    
    _grpRspwn = [getMarkerPos "spwPos", WEST, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >>"Infantry" >>"US_DeltaForceTeam")] call BIS_fnc_spawnGroup;
       {_x setskill 0.5} forEach units _grpRspwn;
                _ldr = leader _grpRspwn;
    
    waitUntil {(_ldr distance _cab) <=200};//named heli will have to fly within 200m of the group waiting at the spawn position for this type of getin to work.
    {_x assignAsCargo _cab; [_x] orderGetIn true;} forEach units _grpRspwn;
    [group _ldr, heli1] execVM "respwn.sqf";

    heli1 waypoint init where you want the reinforcements dropped off:

    {unassignVehicle _x; [_x] orderGetIn false;} foreach assignedCargo (vehicle this);


  8. Interesting point by NodUnit, please watch that video!

    I have seen the media attempt to manipulate events to 'generate' news a number of times recently (reporting locations of government meetings / events in advance to get a crowd to turn up etc.) but I don't think it's deliberate in this case. They have to focus on the gunman as they have nothing else to report at the beginning of a story, if they focus on the victims & families they will be accused of intrusion. Lets face it - asking them 'not to do it' doesn't work, shrieks of 'press freedom' and all that jazz. The unfortunate side effect is the stimulation of the unbalanced in the community, some of whom can't then get the thoughts and images out of their heads. Most of what we see, including the recent school shooting are 'copy cat' killings imho.

    Maybe we should urge families of victims to talk to the 'vultures of the press' sooner, rather than later so they have something meaningful to put on TV. I think family videos of the victims should be released so we get a sense of who died, rather than a list of numbers. After all, the real news here is young lives lost, ruined families and potential that will never be realised, not some idiot with a gun who didn't have the sense to blow his own head off and leave it at that....

    I see sales of AR-15's have rocketed! Must be great to see your feckless, half idiot, beer swilling, weed tootin neighbour running over to the gun shop to buy as much guns and ammunition as possible before they ban sales. I don't know how the average US citizen manages to sleep at night.


  9. You can get classnames easily by looking at the magazine config:

    http://browser.six-projects.net/cfg_magazines/1479056

    The object created from 60Rnd_CMFlareMagazine is "CMflareAmmo"

    I put this in the init of several vehicles and it returns a position everytime I fire a flare:

    this addEventHandler ["fired", "hint format['%1',(getPosATL (nearestObject [(vehicle player), 'CMflareAmmo']))]"];

    If you have a function like this?:

    _obj = nearestObject [(vehicle player), "CMflareAmmo"];
    while (alive _obj) do {
    _pos = getPosATL _obj;
    //your missile tracking stuff to _pos here
    };


  10. Got a script you can put in a waypoint init.

    -Spawns missile

    -Creates explosion, fire, smoke

    -Tail rotor / engine failure and crew exit.

    -Helicopter explodes after crew clear

    - Requires functions module on map

    Example mission: HeliCrash2.Shapur_BAF.zip

    https://dl.dropbox.com/u/37698503/HeliCrash2.Shapur_BAF.zip

    nul = [(vehicle this)] execVM "crash.sqf"; //in helicopter waypoint init

    //nul = [(vehicle this)] execVM "crash.sqf"
    //in helicopter waypoint init
    
    waitUntil {!isNil "bis_fnc_init"};
    _heli = _this select 0;
     _list = assignedCargo _heli;
       _ldr = leader (group (_list select 1));
         _crew = crew _heli;
    
    _heli land "LAND";
    
    _mpos = getMarkerPos "msl";
     _hpos = getPosATL _heli;
       _dir = [_mpos, _hpos] call BIS_fnc_dirTo;
    
    _missile = "M_Igla_AA" createVehicle _mpos;
     _missile setPos [getMarkerPos "msl" select 0, getMarkerPos "msl" select 1, (getMarkerPos "msl" select 2)+3];
       _missile setDir _dir;
    
    //Change the middle value below to get missile trajectory (pitch) correct, missile must pass close to helicopter:
    //[object, pitch, bank] call BIS_fnc_setPitchBank;
    [_missile, 8, 0] call BIS_fnc_setPitchBank;
    
    waitUntil {(_missile distance _heli) <=20};
     deleteVehicle _missile;
    
    //fire and explosion
    [_heli,4.0,120,false,false] spawn BIS_Effects_Burn;
    _b = getPosATL _heli;
      _w = createVehicle ["Sh_125_HE", _b, [], 0, "CAN_COLLIDE"];
        _h = createVehicle ["weaponHolder", _b, [], 0, "CAN_COLLIDE"];
          _w setPosATL (getPosATL _h);
    
    //crash tail rotor failure
    waitUntil {(getpos _heli select 2) <=30};
     _heli setHit ["mala vrtule", 1];
       _heli setFuel 0;
    
    waitUntil {(getpos _heli select 2) <=0.5};
     {unassignvehicle _x; dogetout _x} foreach _list;
       {[_x] joinSilent (group _ldr)} foreach _crew;
         hint "Run! It's going to explode!";
    
    waitUntil {(_ldr distance _heli) >=60};
     _heli setDammage 1;
    


  11. Awesome stuff! Is there a way to make this work if someone picks up a laser designator from a crate instead of them spawning with it?

    It will work for anyone who has the addAction and a laser designator no matter how they got it.

    edit:- in response to your question below I have not tested this for multiplayer - that's up to you. It's only done with single player in mind, sorry have no plans to develop it further but do what you can with it by all means :).

    A10 single pass is this:

    Changed waypoint 1 to "move" - added a flyInheight 500 at the end to it climbs higher - main thing, deleted the Search and Destroy part of the script:

    /*
    A10 Strafe mission by Mattar_Tharkari - A10GAU_12.sqf
    you need a player armed with a laser designator - use special forces Forward Air Controller - for example
    You need a functions module on the map
    Put laser on target, switch on laser, then scroll down for addAction - add this to player init in editor:
    this addaction [("<t color=""#ee6600"">" + ("Store A10 Strafe Target") +"</t>"), "A10GAU_12.sqf","3", 1, false, true];
    The bomb guidance function was originally made for Armed Assault by Venori
    */
    private ["_vehArr","_unit","_range","_pilot","_randDir","_Dist","_spawnPos","_dir_sp","_dirJet","_wp1","_epos","_target","_soundsrc","_Atarget","_aimingQuality","_object","_caller","_id1","_source","_tgtpos","_wp2","_tgtLoc","_gunRuns","_arg","_argNum"];
    
    waitUntil {!isNil "bis_fnc_init"};
    
    _object = _this select 0;
      _caller = _this select 1;
        _id1 = _this select 2;
          _arg = _this select 3; //number of gun attacks passed from action
            _argNum = parseNumber _arg;
    
    _object removeaction _id1;
    
    ///////////////////////////////////////////////////////////////
    //player select primary weapon/turn laser off
    
    if ((primaryWeapon _caller) != "") then {
     private['_type', '_muzzles'];
      _type = primaryWeapon _caller;
        _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");
    
    if (count _muzzles > 1) then {_caller selectWeapon (_muzzles select 0);}
     else
       {_caller selectWeapon _type;};
    };
    
    ////////////////////////////////////////////////////////////////
    //set up target position
    _source = laserTarget _caller;
    
    if (isNull _source) exitWith {
     _caller commandChat "Target System Aborted: No laser target found.";
       _caller addaction [("<t color=""#ee6600"">" + ("Store A10 Strafe Target") +"</t>"), "A10GAU_12.sqf","3", 1, false, true];
    };
    
    _tgtpos = getPosATL laserTarget _caller;
     _target = "HeliHEmpty" createVehicle _tgtpos;
       _target setPosATL [ getPosATL _target select 0, getPosATL _target select 1, 0];
         _soundsrc = "HeliHEmpty" createVehicle _tgtpos;
    
    //////////////////////////////////////////////////////////
    //A10 spawn
    
    _randDir = random(360);
    _dist = 2000;//radius for A10 to spawn minimum 2000
     _spawnPos = [(_tgtpos select 0) + (_dist * sin(_randDir)), (_tgtpos select 1) + (_dist * cos(_randDir)), (_tgtpos select 2) + 1200];
    
    _dir_sp = [_spawnPos, _tgtpos] call BIS_fnc_dirTo;
     _vehArr = [_spawnPos, _dir_sp, "A10_US_EP1", WEST] call bis_fnc_spawnvehicle;
       _unit = _vehArr select 0;
    
    _pilot = (_vehArr select 1) select 0;
     _pilot sidechat "Hog 22: Target Position authenticated, inbound";
    
    _unit setBehaviour "CARELESS";
     _unit setCombatMode "BLUE";
    
    _unit removeMagazinesTurret ["4Rnd_GBU12",[-1]];
     _unit removeMagazinesTurret ["14Rnd_FFAR",[-1]];
       _unit removeMagazinesTurret ["1350Rnd_30mmAP_A10",[-1]];
         _unit removeMagazinesTurret ["2Rnd_Sidewinder_AH1Z",[-1]];
    
     _dirJet = direction _unit;
       _unit setVelocity [sin ((_dirJet) * 100), cos ((_dirJet) * 100), 0];
         _unit flyinheight 200;
           _unit allowDamage false;
    
    //////////////////////////////////////////////////////////////
    //waypoints
    _wp1 = (group _unit) addWaypoint [_tgtpos, 1];
     _wp1 setWaypointType [color="#FF0000"]"MOVE"[/color];
    
    _wp2 = (group _unit) addWaypoint [_spawnPos, 2];
     _wp2 setWaypointType "MOVE";
    
       _wp2 setWaypointStatements ["true", "
    {deletevehicle _unit} foreach crew (vehicle this);
    	deleteVehicle (vehicle this);
    		var_gunRuns = 0;
    player addaction [('<t color=""#ee6600"">' + ('Store A10 Strafe Target') +'</t>'),'A10GAU_12.sqf','3', 1, false, true];
    "];
    
    //deletes A10 at WP2 and creates action for player again.
    
    
    //////////////////////////////////////////////////////////////
    //Auto flares for A10
    
    fnc_flares = {
    private ["_list","_airVec","_prm","_cls","_plt","_msl"];
    _airVec = _this select 0;
     _prm = 750;
       _plt = driver _airVec;
    
    while {alive _airVec} do {
     	  _list = (position _airVec) nearObjects ["MissileBase",_prm];
    
    if (count _list >=1) then {
      _msl = _list select 0;
    	    _cls = typeOf _msl;
    
    if (_cls == "M_Strela_AA"|| _cls == "M_Stinger_AA" || _cls == "M_Igla_AA") then{
     _airVec action ["useWeapon", _airVec, _plt, 11];
       sleep 0.5;
    
         };
       };
     };
    };
    
    [_unit] spawn fnc_flares;
    
    ////////////////////////////////////////////////////////////////
    //GAU-8 Strafe
    var_gunRuns = 0;
    
    fnc_randomPos = {
    
    private ["_p","_r","_d","_h","_randPos"];
    _p = _this select 0;
      _r = random 15;
        _d = random 360;
    _h = random 15;
    _randPos = [((_p select 0) + (_r * sin _d)),((_p select 1) + (_r * cos _d)),(_p select 2) +_h];
     _randPos
    };
    
    
    fnc_steelrain = {
    
    private ["_kzPos","_kz","_kzPos2"];
     _kz = _this select 0;
    
    for "_i" from 0 to 40 do {
     _kzPos = [_kz] call fnc_randomPos;
       "B_30mm_HE" createVehicle _kzPos;
    };
    
    for "_j" from 0 to 40 do {
     _kzPos2 = [_kz] call fnc_randomPos;
       "B_30mmA10_AP" createVehicle _kzPos2;
    
    sleep 0.001;
     };
    };
    
    _range = 1000;
     waitUntil {(_target distance _unit) <= _range};
       _pilot sidechat "Hog22: Weapons Hot! Guns!";
    
    _unit say3D "A10attack";
     _soundsrc say3D "A10rounds";
    
    _tgtLoc = getPosATL _target;
     [_tgtLoc] call fnc_steelrain;
       sleep 5;
         deleteVehicle _soundsrc;
        [color="#FF0000"] _unit flyinheight 500;[/color]
    ///////////////////////////////////////////////////////////////////////////
    


  12. I'm a fan of:

    [getPos mySpawnPos, 180, "BMP3", EAST] call bis_fnc_spawnvehicle;

    -Just so no one forgets: you need to put a Functions Module on the map for this function to work.

    -If there is no enemy on the map, it will spawn as empty.

    -Clarifying the above, you either need to use createCenter to create a side, or place a unit of the desired side on the map (probability0%), otherwise the vehicle spawns empty.

    http://community.bistudio.com/wiki/BIS_fnc_spawnVehicle

    http://community.bistudio.com/wiki/Category:ArmA_2:_Functions


  13. Found it!

    XoHCZ6WUSGo

    Here is a link to an example mission containing both the JDAM and a GAU12 strafe - you need to download for the GAU12 script to work as it has A10 custom sounds plus description.ext

    A10examples2.Takistan.zip

    https://dl.dropbox.com/u/37698503/A10examples2.Takistan.zip

    A10 will strafe stored laser coordinates on 1st pass then search for enemy vehicles.

    /*
    A10 Strafe mission by Mattar_Tharkari - A10GAU_12.sqf
    you need a player armed with a laser designator - use special forces Forward Air Controller - for example
    You need a functions module on the map
    A10 sounds taken from publically available range recordings - www.freesound.org
    Put laser on target, switch on laser, then scroll down for addAction - add this to player init in editor:
    this addaction [("<t color=""#ee6600"">" + ("Store A10 Strafe Target") +"</t>"), "A10GAU_12.sqf","3", 1, false, true];
    3 is the number of attacks allowed during the loiter / S&D (value will also need altering under targets / waypoints below
    */
    private ["_vehArr","_unit","_range","_pilot","_randDir","_Dist","_spawnPos","_dir_sp","_dirJet","_wp1","_epos","_target","_soundsrc","_Atarget","_aimingQuality","_object","_caller","_id1","_source","_tgtpos","_wp2","_tgtLoc","_gunRuns","_arg","_argNum"];
    
    waitUntil {!isNil "bis_fnc_init"};
    
    _object = _this select 0;
      _caller = _this select 1;
        _id1 = _this select 2;
          _arg = _this select 3; //number of gun attacks passed from action
            _argNum = parseNumber _arg;
    
    _object removeaction _id1;
    
    ///////////////////////////////////////////////////////////////
    //player select primary weapon/turn laser off
    
    if ((primaryWeapon _caller) != "") then {
     private['_type', '_muzzles'];
      _type = primaryWeapon _caller;
        _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");
    
    if (count _muzzles > 1) then {_caller selectWeapon (_muzzles select 0);}
     else
       {_caller selectWeapon _type;};
    };
    
    ////////////////////////////////////////////////////////////////
    //set up target position
    _source = laserTarget _caller;
    
    if (isNull _source) exitWith {
     _caller commandChat "Target System Aborted: No laser target found.";
       _caller addaction [("<t color=""#ee6600"">" + ("Store A10 Strafe Target") +"</t>"), "A10GAU_8.sqf","3", 1, false, true];
    };
    
    _tgtpos = getPosATL laserTarget _caller;
     _target = "HeliHEmpty" createVehicle _tgtpos;
       _target setPosATL [ getPosATL _target select 0, getPosATL _target select 1, 0];
         _soundsrc = "HeliHEmpty" createVehicle _tgtpos;
    
    //////////////////////////////////////////////////////////
    //A10 spawn
    
    _randDir = random(360);
    _dist = 2000;//radius for A10 to spawn minimum 2000
     _spawnPos = [(_tgtpos select 0) + (_dist * sin(_randDir)), (_tgtpos select 1) + (_dist * cos(_randDir)), (_tgtpos select 2) + 400];
    
    _dir_sp = [_spawnPos, _tgtpos] call BIS_fnc_dirTo;
     _vehArr = [_spawnPos, _dir_sp, "A10_US_EP1", WEST] call bis_fnc_spawnvehicle;
       _unit = _vehArr select 0;
    
    _pilot = (_vehArr select 1) select 0;
     _pilot sidechat "Hog 21: Target Position authenticated, inbound";
    
    _unit setBehaviour "CARELESS";
     _unit setCombatMode "BLUE";
    
    _unit removeMagazinesTurret ["4Rnd_GBU12",[-1]];
     _unit removeMagazinesTurret ["14Rnd_FFAR",[-1]];
       _unit removeMagazinesTurret ["1350Rnd_30mmAP_A10",[-1]];
         _unit removeMagazinesTurret ["2Rnd_Sidewinder_AH1Z",[-1]];
           _unit removeMagazinesTurret ["2Rnd_Maverick_A10",[-1]];
    
    _unit setPosATL [ getPosATL _unit select 0, getPosATL _unit select 1, (getPosATL _unit select 2) +800];
     _dirJet = direction _unit;
       _unit setVelocity [sin ((_dirJet) * 100), cos ((_dirJet) * 100), 0];
         _unit flyinheight 200;
           _unit allowDamage false;
    
    //////////////////////////////////////////////////////////////
    //waypoints
    _wp1 = (group _unit) addWaypoint [_tgtpos, 1];
     _wp1 setWaypointType "SAD";
    
    _wp2 = (group _unit) addWaypoint [_spawnPos, 2];
     _wp2 setWaypointType "MOVE";
    
       _wp2 setWaypointStatements ["true", "
    {deletevehicle _unit} foreach crew (vehicle this);
    	deleteVehicle (vehicle this);
    		var_gunRuns = 0;
    player addaction [('<t color=""#ee6600"">' + ('Store A10 Strafe Target') +'</t>'),'A10GAU_8.sqf','3', 1, false, true];
    "];
    
    //deletes A10 at WP2 and creates action for player again.
    
    ////////////////////////////////////////////////////////////////
    
    
    //_unit addMagazineTurret ["2Rnd_Maverick_A10",[-1]];
    {_unit addMagazineTurret ["2Rnd_Maverick_A10",[-1]]} forEach [1,2];
    reload _unit;
    (vehicle _pilot) selectWeapon "MaverickLauncher";
    
    //////////////////////////////////////////////////////////////
    //Auto flares for A10
    
    fnc_flares = {
    private ["_list","_airVec","_prm","_cls","_plt","_msl"];
    _airVec = _this select 0;
     _prm = 750;
       _plt = driver _airVec;
    
    while {alive _airVec} do {
     	  _list = (position _airVec) nearObjects ["MissileBase",_prm];
    
    if (count _list >=1) then {
      _msl = _list select 0;
    	    _cls = typeOf _msl;
    
    if (_cls == "M_Strela_AA"|| _cls == "M_Stinger_AA" || _cls == "M_Igla_AA") then{
     _airVec action ["useWeapon", _airVec, _plt, 11];
       sleep 0.5;
    
         };
       };
     };
    };
    
    [_unit] spawn fnc_flares;
    
    ////////////////////////////////////////////////////////////////
    //GAU-8 Strafe
    var_gunRuns = 0;
    
    fnc_randomPos = {
    
    private ["_p","_r","_d","_h","_randPos"];
    _p = _this select 0;
      _r = random 15;
        _d = random 360;
    _h = random 15;
    _randPos = [((_p select 0) + (_r * sin _d)),((_p select 1) + (_r * cos _d)),(_p select 2) +_h];
     _randPos
    };
    
    
    fnc_steelrain = {
    
    private ["_kzPos","_kz","_kzPos2"];
     _kz = _this select 0;
    
    for "_i" from 0 to 40 do {
     _kzPos = [_kz] call fnc_randomPos;
       "B_30mm_HE" createVehicle _kzPos;
    };
    
    for "_j" from 0 to 40 do {
     _kzPos2 = [_kz] call fnc_randomPos;
       "B_30mmA10_AP" createVehicle _kzPos2;
    
    sleep 0.001;
     };
    };
    
    _range = 1000;
     waitUntil {(_target distance _unit) <= _range};
       _pilot sidechat "Hog22: Weapons Hot! Guns!";
    
    _unit say3D "A10attack";
     _soundsrc say3D "A10rounds";
    
    _tgtLoc = getPosATL _target;
     [_tgtLoc] call fnc_steelrain;
       sleep 5;
         deleteVehicle _soundsrc;
    
    //////////////////////////////////////////////////////
    //Search and Destroy
    
    while {alive _unit} do {
    _Atarget = assignedTarget _unit;
      _epos = getPosATL _Atarget;
        _aimingQuality = _unit AimedAtTarget [_Atarget];
    
    if (_aimingQuality >= 0.7) then {
     _pilot sidechat "Hog22: Attacking hostile vehicles - guns!";
       var_gunRuns = var_gunRuns +1;
    
    _Atarget say3D "A10rounds";
     _unit say3D "A10attack2";
    
    [_epos] call fnc_steelrain;
     sleep 6;
       };
    
    //Number of allowed gunruns
    if (var_gunRuns == _argNum) exitwith{
     _pilot sidechat "Hog22: Winchester, RTB";
    var_gunRuns = 0;
    
    (group _unit) setCombatMode "BLUE";
     deleteWaypoint [(group _unit), 1];
       (group _unit) setCurrentWaypoint [(group _unit), 2];
     };
    };
    
    


  14. Here you go - this is the guided JDAM script

    Advantages:

    A10 will fly a more realistic attack.

    It drops bomb on 1st pass

    Bomb fall is still simulated

    A10 has auto flares

    Player switches back to primary weapon after laser coordinates are stored

    It's all in 1 script and called from 1 addAction

    I promised a gun run script but can't find it - think it may be on a memory stick at work - will post a link in a few days. I used aimedAtTarget in a loop to check the A10 was pointing at the target before simulating a strafe - works best demonstrated in an example mission.

    A10JDAM.sqf

    Put this in players init to test:

    this addaction [("<t color=""#ee6600"">" + ("Store JDAM Target Positn") +"</t>"), "A10JDAM.sqf","", 1, false, true];

    /*
    A10 JDAM boming mission by Mattar_Tharkari - A10JDAM.sqf
    you need a player armed with a laser designator - use special forces Forward Air Controller - for example
    You need a functions module on the map
    Put laser on target, switch on laser, then scroll down for addAction - add this to player init in editor:
    this addaction [("<t color=""#ee6600"">" + ("Store JDAM Target Positn") +"</t>"), "A10JDAM.sqf","", 1, false, true];
    The bomb guidance function was originally made for Armed Assault by Venori
    */
    
    private ["_bpos","_vehArr","_unit","_range","_pilot","_target","_velocityForCheck","_object","_caller","_id1","_tgtpos","_randDir","_dist","_spawnPos","_dir_sp","_dirJet","_wp1","_wp2","_source","_jdam","_missileSpeed","_JDAMguide"];
    
    waitUntil {!isNil "bis_fnc_init"};
    _object = _this select 0;
      _caller = _this select 1;
        _id1 = _this select 2;
    
    _object removeaction _id1;
    
    ///////////////////////////////////////////////////////////////
    //player select primary weapon/turn laser off
    
    if ((primaryWeapon _caller) != "") then {
     private['_type', '_muzzles'];
      _type = primaryWeapon _caller;
        _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");
    
    if (count _muzzles > 1) then {_caller selectWeapon (_muzzles select 0);}
     else
      {_caller selectWeapon _type;};
    };
    ////////////////////////////////////////////////////////////////
    //set up target position
    _source = laserTarget _caller;
    
    if (isNull _source) exitWith {
    player commandChat "Target System Aborted: No laser target found.";
      _caller addaction [("<t color=""#ee6600"">" + ("Store JDAM Target Positn") +"</t>"), "A10JDAM.sqf","", 1, false, true];
    };
    
    _tgtpos = getPosATL laserTarget _caller;
     _target = "HeliHEmpty" createVehicle _tgtpos;
       _target setPosATL [ getPosATL _target select 0, getPosATL _target select 1, 0];
    
    //////////////////////////////////////////////////////////
    //A10 spawn
    
    _randDir = random(360);
    _dist = 2000;//radius for A10 to spawn minimum 2000
     _spawnPos = [(_tgtpos select 0) + (_dist * sin(_randDir)), (_tgtpos select 1) + (_dist * cos(_randDir)), (_tgtpos select 2) + 500];
    
    _dir_sp = [_spawnPos, _tgtpos] call BIS_fnc_dirTo;
     _vehArr = [_spawnPos, _dir_sp, "A10_US_EP1", WEST] call bis_fnc_spawnvehicle;
       _unit = _vehArr select 0;
    
    _pilot = (_vehArr select 1) select 0;
     _pilot sidechat "Hog 21: Target Position authenticated, inbound";
    
    _unit setBehaviour "CARELESS";
     _unit setCombatMode "BLUE";
    
    _unit removeMagazinesTurret ["4Rnd_GBU12",[-1]];
     _unit removeMagazinesTurret ["14Rnd_FFAR",[-1]];
       _unit removeMagazinesTurret ["1350Rnd_30mmAP_A10",[-1]];
         _unit removeMagazinesTurret ["2Rnd_Sidewinder_AH1Z",[-1]];
           _unit removeMagazinesTurret ["2Rnd_Maverick_A10",[-1]];
    
    _unit setPosATL [ getPosATL _unit select 0, getPosATL _unit select 1, (getPosATL _unit select 2) +800];
     _dirJet = direction _unit;
       _unit setVelocity [sin ((_dirJet) * 100), cos ((_dirJet) * 100), 0];
         _unit flyinheight 600;
           _unit allowDamage false;
    
    //////////////////////////////////////////////////////////////
    //waypoints
    _wp1 = (group _unit) addWaypoint [_tgtpos, 1];
     _wp1 setWaypointType "MOVE";
    
    _wp2 = (group _unit) addWaypoint [_spawnPos, 2];
     _wp2 setWaypointType "MOVE";
    
       _wp2 setWaypointStatements ["true", "
    {deletevehicle _unit} foreach crew (vehicle this);
    	deleteVehicle (vehicle this);
    player addaction [('<t color=""#ee6600"">' + ('Store JDAM Target Positn') +'</t>'),'A10JDAM.sqf','', 1, false, true];
    "];
    
    //deletes A10 at WP2 and creates action for player again.
    
    ////////////////////////////////////////////////////////////////
    //spawn JDAM
    _range = 800;
    waitUntil {(_target distance _unit) <= _range};
    
    _pilot sidechat "Tusk 22: Weapons Hot! JDAM away!";
     _bmpos = [getPosATL _unit select 0, getPosATL _unit  select 1, (getPosATL _unit  select 2)-10];
       _jdam = "Bo_Mk82" createVehicle _bmpos;
         _missileSpeed = 100;
    
    //////////////////////////////////////////////////////////////////
    //guiding the JDAM
    // original Function file for Armed Assault
    // Created by: Venori
    
    _JDAMguide = {
    
    private ["_velocityX","_velocityY","_velocityZ","_travelTime","_relDirHor","_relDirVer"];
    
    //altering the direction, pitch and trajectory of the missile
    if (_jdam distance _target > (_missileSpeed / 20)) then {
     _travelTime = (_target distance _jdam) / _missileSpeed;
       _relDirHor = [_jdam, _target] call BIS_fnc_DirTo;
         _jdam setDir _relDirHor;
    
    _relDirVer = asin ((((getPosASL _jdam) select 2) - ((getPosASL _target) select 2)) / (_target distance _jdam));
    _relDirVer = (_relDirVer * -1);
     [_jdam, _relDirVer, 0] call BIS_fnc_setPitchBank;
    
    _velocityX = (((getPosASL _target) select 0) - ((getPosASL _jdam) select 0)) / _travelTime;
    _velocityY = (((getPosASL _target) select 1) - ((getPosASL _jdam) select 1)) / _travelTime;
    _velocityZ = (((getPosASL _target) select 2) - ((getPosASL _jdam) select 2)) / _travelTime;
    
    };
    
    [_velocityX, _velocityY, _velocityZ]
    };
    
    call _JDAMguide;
    
    //missile flying
    while {alive _jdam} do {
    _velocityForCheck = call _JDAMguide;
    
    if ({(typeName _x) == (typeName 0)} count _velocityForCheck == 3) then {_jdam setVelocity _velocityForCheck};
    sleep (0.05)
    };
    
    //////////////////////////////////////////////////////////////
    //Auto flares for A10
    
    fnc_flares = {
    private ["_list","_airVec","_prm","_cls","_plt","_msl"];
    _airVec = _this select 0;
     _prm = 750;
       _plt = driver _airVec;
    
    while {alive _airVec} do {
     	  _list = (position _airVec) nearObjects ["MissileBase",_prm];
    
    if (count _list >=1) then {
      _msl = _list select 0;
    	    _cls = typeOf _msl;
    
    if (_cls == "M_Strela_AA"|| _cls == "M_Stinger_AA" || _cls == "M_Igla_AA") then{
     _airVec action ["useWeapon", _airVec, _plt, 11];
       sleep 0.5;
    
         };
       };
     };
    };
    
    [_unit] spawn fnc_flares;
    
    //////////////////////////////////////////////////////////////


  15. Works ok for me - I tried it on Utes and I get apaches spawning in a different place every time. Some maps have more location logics than others - if your testing this in the Desert Island you will find spawning locations limited! Locations only work when there are plenty of locations to choose from e.g. in Takistan / Chernarus. Utes / Zargabad/ Shapur have fewer and the Desert is nearly empty!

    Also looking at that script you aren't calling the function 11 times - you are calling it once elsewhere and then running the same position 11 times. You need a:

    _random_Poistions = ["CtrMkr"] call fnc_locations;

    at the top there (change variable to local).

×