Jump to content
Sign in to follow this  
dar

A10 gun run script

Recommended Posts

Hey people,

im currently busy with a script for a dynamic A10 gun run which the player can call in via radio.

this is the script, I found it here and modified it a little: http://hx3.de/editing-scripting-167/a10-airstrike-19793/ It is not my work, I just try to implement it in a custom mission.

Thats my version:

if (!isServer) exitWith {};

clicked = 0; hint "Click on map to set the target location";

sleep 1;

openmap true;

onMapSingleClick "target setpos [_pos select 0, _pos select 1, 0];

clicked = 1;

openmap false;onMapSingleClick ''; true;"; waitUntil {(clicked == 1)};

hint "";

[West,"HQ"] sideChat "Roger that, A10 is inbound ETA 20.";

sleep 2;

_mark = "SmokeShellRed" Createvehicle [(getPos target select 0),(getPos target select 1),(getPos target select 2)+2];

_ma2 = creategroup west;

AirSupport = createvehicle ["A10_US_EP1", start1, [], 70, "FLY"];

_m1 = _ma2 createUnit ["US_Soldier_Pilot_EP1", position start1, [], 0, "form"];

_m1 setRank "COLONEL";

_m1 moveInDriver AirSupport;

_wp = _ma2 addWaypoint [position start1, 0];

_wp1 = _ma2 addWaypoint [position target, 0];

_wp2 = _ma2 addWaypoint [position egress, 0];

_wp3 = _ma2 addWaypoint [position doitagain, 0];

[_ma2, 1] setWaypointType "Move";

[_ma2, 1] setWaypointSpeed "FULL";

[_ma2, 1] setWaypointBehaviour "CARELESS";

[_ma2, 1] setWaypointStatements ["true", "AirSupport flyInHeight 40;"];

[_ma2, 2] setWaypointType "MOVE";

[_ma2, 2] setWaypointSpeed "FULL";

[_ma2, 2] setWaypointBehaviour "CARELESS";

[_ma2, 2] setWaypointStatements ["true", "AirSupport flyInHeight 70;"];

[_ma2, 3] setWaypointType "Move";

[_ma2, 3] setWaypointSpeed "FULL";

[_ma2, 3] setWaypointBehaviour "CARELESS";

[_ma2, 3] setWaypointStatements ["true", "AirSupport flyInHeight 70;"];

[_ma2, 4] setWaypointType "CYCLE";

[_ma2, 4] setWaypointSpeed "FULL";

[_ma2, 4] setWaypointBehaviour "CARELESS";

[_ma2, 4] setWaypointStatements ["true", "AirSupport flyInHeight 70;"];

sleep 120;

[West,"HQ"] sideChat "A10 is RTB.";

deleteVehicle AirSupport;

DeleteGroup _ma2;

I want the A10 to spawn, fly to the mapclick marked position, ATTACK the marked position with the GAU8, then turn around and do that til it is deleted.

Thats what happens now: I call him in, the bomber flys right over the position turns around (takes about half a minute til he comes back) and starts to fire on any targets in the area. When I give Laser targets with the SOFLAM he will attack them with a bomb during his first approach.

If I add this:

Airsupport removeWeapon "MaverickLauncher";

Airsupport removeWeapon "SidewinderLaucher_AH1Z";

Airsupport removeWeapon "FFARLauncher_14";

Airsupport removeWeapon "BombLauncherA10";

He will engage nothing during his first approach, just like when I give him no laser targets.

Any ideas how to get this working?

Share this post


Link to post
Share on other sites

If you just want a gun run removing the other weapons is correct. If I'm not mistaken with setWaypointBehaviour "CARELESS";

careless behaviour causes units to ignore all targets. You can try changing it to "combat" and maybe add this also: setCombatMode "RED".

Share this post


Link to post
Share on other sites

clicked = 0; 
hint "Click on map to set the target location";
sleep 1;
openmap true;
onMapSingleClick {

onmapsingleclick{};

target setpos [_pos select 0, _pos select 1, 0];

clicked = 1;

openmap false; 
};
waitUntil {(clicked == 1)};

IMO using {} is a better way of writing code within onMapSingleClick if you're using multiple lines.

Also:

deleteVehicle AirSupport;
DeleteGroup _ma2;

A better way to write this might be:

 {deletevehicle _x} foreach crew AirSupport + [Airsupport]

And maybe add a Range check to prevent it looking ugly (like, A10 is flying right above and then it's suddenly gone).

About your main problem though, as Zulu1 said, Careless will cause the A10 to ignore everything. I also suggest to change the waypointtype to Search & Destroy ("SAD") above the target area instead of Move.

Share this post


Link to post
Share on other sites

Thanks for those quick replies, I will try it. Anyway I also thought about that disappearing thing but I have no idea how to implement such a range check so I guess I'll take the chance that it will be deleted when I dont look at it.

Share this post


Link to post
Share on other sites

For the plane deleting issue I suppose you could add a WP 3000m away from the player and once the plane is about 2500-3000m away from the player delete it.

Share this post


Link to post
Share on other sites

Ok I edited the first and second waypoint

[_ma2, 1] setWaypointType "Move";

[_ma2, 1] setWaypointSpeed "FULL";

[_ma2, 1] setWaypointBehaviour "CARELESS";

[_ma2, 1] setWaypointStatements ["true", "AirSupport flyInHeight 40; AirSupportset CombatMode "RED";"];

[_ma2, 2] setWaypointType "SAD";

[_ma2, 2] setWaypointSpeed "FULL";

[_ma2, 2] setWaypointBehaviour "COMBAT";

[_ma2, 2] setWaypointStatements ["true", "AirSupport flyInHeight 70;"];

I removed all weapons but the cannon.

The result: nothing. A10 approaches, flys over the target area and follows the waypoints. When he comes back he attacks any targets he saw on his first flyover but mainly vehicles and in 100% of the tests I did the bomber fired at some enemys about 1km away from my position, something I didnt care about at this time and I didnt order an airstrike for.

Wether I mark a laser target or not doesnt matter.

Edited by Dar

Share this post


Link to post
Share on other sites

I made a mission some time ago which was basically a simple airstrike where an A10 would fly over the target area and drop bombs until there's none left and then leave. The problem with this is that the bombs never go past the object selected so it'll only hit the actual target and the targets infront of that. I used a fixed spawnpoint during the missiontesting but that's easily changeable.

If you want to take a look, here's the script:

// Creating the plane & pilot

_grp = creategroup WEST;
setfire = true;


hintSilent "Select your firedirection";
onMapSingleClick {
  //We only need this event to fire once, once that happens we reset it
  onMapSingleClick {};

  //ASL height
  _height = getTerrainHeightASL _pos;

  //Move the object
  ASTarget setPosASL [_pos select 0, _pos select 1, _height];

  //Set variable
  setfire = false;
};  

waituntil {!setfire};
_targets = nearestObject [ASTarget, "Tank"];
hintSilent format ["%1",_targets];
if (!setfire) then {
"Firedirection" setMarkerPos getpos ASTarget;
// plane = createvehicle ["AV8B2", getmarkerpos "unitspawn",[],0,"FLY"];
plane = createvehicle ["A10", getmarkerpos "unitspawn",[],0,"FLY"];
plane setposATL [(getposATL plane select 0), getposATL plane select 1, 200];
plane setspeedmode "full";
plane setDir 90;
plane setvelocity [100,0,0];
plane allowDamage false;
pilot = _grp createunit ["USMC_Soldier_Pilot",getmarkerpos "unitspawn",[],0,"FORM"];
pilot moveindriver plane;
pilot action ["LandGearUp", plane];
pilot doMove getpos _targets;
pilot doTarget _targets;
pilot flyinheight 300;
pilot allowdamage false;
};

// Dropping MK82

/* for [{_i = 0},{pilot distance _targets < 1500 && _i <= 2},{_i = _i + 1}] do {
MyGameLogic action ["useWeapon",plane,pilot,5];
hintSilent format ["%1",_i];
sleep 0.2;
}; */
waituntil {pilot distance _targets < 500};

//Declaring variable to limit bomb usage
_i = 0;

// A10 
while {_i <= 3} do {
MyGameLogic action ["useWeapon",plane,pilot,7];
sleep 1;
_i = _i + 1;
hintSilent format ["%1",_i];
};

/* AV8B2
while {_i <= 4} do {
MyGameLogic action ["useWeapon",plane,pilot,5];
sleep 2;
_i = _i + 1;
hintSilent format ["%1",_i];
}; */

_pwp = _grp addWaypoint [getmarkerpos "planewp",0];
pilot doMove (getMarkerPos "planewp"); 

The script basically used nearestObject to give the pilot a valid target (since an empty target isn't valid and the pilot won't drop any bombs regardless of what you do) and then basically tells the pilot to drop bombs all over the place. It isn't 100% accurate (the actual airstrike) but IMO it shouldn't be 100% accurate.

Here's the thread, scroll down to the bottom if you want an example mission (the script is both useable with an AV8B (without LGBs) and an A10)

//Edit

To go a bit more in-depth about the script, ASTarget is an invisible HPad, which is used to determine the nearestObject around it (for testing purposes I placed 3 Tanks in a triangle-shaped form and made it so it only checks for tanks). Firedirection is a simple marker. You can always add "Car" etc to nearestObject, it will only choose 1 object and target that one though.

Using sleep is important when you're planning to use while-loops to drop bombs because without it all the bombs just go drop instantly.

(Actually I just noticed this isn't totally what you want but I hope it's still helpful in some way.)

//Edit

So just to clarify I've also had the problem of the plane not targeting anything when simply moving to a position and telling the plane to target everything. It did nothing, came back and killed everything. The above way is how I fixed it.

Edited by tryteyker

Share this post


Link to post
Share on other sites

Ok I tried your script and removed all weapons but the cannon but still the pilot seems to simply iognore every doTarget command he recieves as the bomber again just flies over the target area and when he comes back his priority are some vehicles far far aways from whatever I marked for him to shoot at. It is annoying. This already took far too long now as I spent the whole day with this. I think I'll just come back to the SOM module with its CAS support option and forget about those gau8s.

Anyway thanks for your help.

Share this post


Link to post
Share on other sites

I have something special that you will like - will post tomorrow as I am being nagged about inconsequential stuff like Xmas shopping!!

1 is an A10 with custom sounds that strafes and fires AGM-65s 1st pass - then attacks anyother enemy vehicles.

1 is a spawned bomb that will track to a laser target 1st pass.

Share this post


Link to post
Share on other sites

Sounds great looking forward to it.

Share this post


Link to post
Share on other sites

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;

//////////////////////////////////////////////////////////////

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

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];
 };
};

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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]
///////////////////////////////////////////////////////////////////////////

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites
It will work for anyone who has the addAction and a laser designator no matter how they got it.

I just didn't want people who don't have the designator to have the option to call it in and get the "Target System Aborted: No laser target found."

Also trying to make the a10 after its initial gun-run with the GAU8 to fly away and delete itself instead of coming back round and engaging targets.

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
Sign in to follow this  

×