Search the Community
Showing results for tags 'gun run'.
Found 1 result
-
mgi scripts MGI GUN RUN (on BI CAS module)
pierremgi posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
MGI GUN RUN Last update: 01/05/2020 Hi all, Here is another script to add a specific gun run, calling a virtual or real CAS. This script is to copy/paste inside BI init CAS module. Nothing more to do! The code will search for "cannon" or "Gatling" in the pilot's weapon. So far, it doesn't work for gunners. You can see "no pilot cannon" in the sub-menu. If you find some non-listed pilot's cannon, let me know. Tips: - Always place your module/aircraft at 2 km from a target area. It's far better for a straight-in approach. You can even place them outside of the map. - Don' try to repeat the CAS too soon with a real aircraft. It will turn around the target without aiming it. Don't forget, pilots are dumb (I can say that referring to my own career). - At this time, Buzzard is far more precise than Wipeout which generously spread ammo with poor efficiency. Code to copy/paste in init field of the CAS module: MGI_CAS_MODULE_1 = this; MGI_CAS = compileFinal " if !(GUNRUNCAS) exitWith {}; private _isVirtual = ({_x isKindOf 'air'} count synchronizedObjects MGI_CAS_MODULE_1 ==0); private _pilot = player getVariable 'BIS_SUPP_selectedProvider'; private _veh = vehicle _pilot; private _home = getPos MGI_CAS_MODULE_1; private _trts = (_veh WeaponsTurret [-1]) select { getText (configfile >> 'CfgWeapons' >> _x >> 'nameSound') == 'cannon'}; waitUntil {!isNil {_pilot getVariable 'BIS_SUPP_requester'} && {!isNull (_pilot getVariable 'BIS_SUPP_requester')}}; private _requester = _pilot getVariable 'BIS_SUPP_requester'; 'Gun run requested' remoteExec ['hint',_requester]; waitUntil {!isnil {_pilot getVariable 'BIS_SUPP_supportRunCoords'}}; private _coords = _pilot getVariable 'BIS_SUPP_supportRunCoords'; private _alt = getTerrainHeightASL _coords; private _limit = [40,90] select (_veh distance2D _coords < 2500); _pilot setCombatMode 'BLUE'; _veh flyInHeightASL [_alt +500,_alt +500,_alt +500]; waitUntil {_veh distance2D _coords < 2000}; if (!isNil 'BIS_SUPP_laserTGT') then {deleteVehicle BIS_SUPP_laserTGT; BIS_SUPP_laserTGT = nil}; private _timer = diag_tickTime; _veh flyInHeightASL [_alt +100,_alt +100,_alt +100]; private _resultOK = false; 'In sight' remoteExec ['hint',_requester]; private _typeForIndep = (WEST getFriend RESISTANCE >0.6); private _tgttype = ['laserTargetE','laserTargetW'] select (side _veh == WEST or (side _veh == RESISTANCE && _typeForIndep)); private _tgt = createVehicle [_tgttype,_coords,[],0,'none']; if (count _trts > 0) then { _trt = _trts select 0; private _mags = (getArray (configfile >> 'CfgWeapons' >> _trt >> 'magazines')) arrayIntersect (_veh magazinesTurret [-1]); comment ""private _cnt = getNumber (configFile >> 'cfgMagazines' >> _mags select 0 >> 'count')""; _pilot setCombatMode 'RED'; _pilot reveal [_tgt,4]; _veh selectWeaponTurret [_trt,[-1]]; private _cnt =_veh magazineTurretAmmo [_veh currentMagazineTurret [-1],[-1]]; while {diag_tickTime < _timer + _limit} do { _tgt setPosASL (getPosASL _tgt vectorAdd [0,0,(0.18 * (_veh distance2D _tgt)) -270]); _veh selectWeaponTurret [_trt,[-1]]; _veh doTarget _tgt; if ((_veh weaponDirection _trt vectorCos (AGLToASL _coords vectorDiff (eyepos _pilot))) > 0.999) then { [[_veh,_trt], BIS_fnc_fire] remoteExec ['call',_veh]; if (_veh magazineTurretAmmo [_veh currentMagazineTurret [-1],[-1]] < _cnt) then {_resultOK = true}; } else { _pilot lookAt _tgt }; uiSleep .01; }; }; if (!_resultOK) then {_pilot setVariable ['BIS_SUPP_failed',true]}; (['Gun run aborted','Gun run terminated, resuming support'] select _resultOK) remoteExec ['hint',_requester]; if !(_isVirtual) then { waitUntil {waypointType [group _veh,currentWaypoint group _veh] == 'MOVE'}; [group _veh,currentWaypoint group _veh] setWaypointPosition [_home,0]; [group _veh,currentWaypoint group _veh] setWaypointStatements ['true','']; _veh setFuel 1; {_veh setAmmo [_x, 2000]} forEach _trts; }; _pilot setVariable ['BIS_SUPP_supporting',false]; if (_isVirtual && alive _veh) then {uiSleep 120; deleteVehicle _veh}; "; 0 = MGI_CAS_MODULE_1 spawn { while {true} do { GUNRUNCAS = false; waitUntil {uiSleep 0.2; !isnil {player getVariable "BIS_SUPP_selectedProvider"}}; waitUntil {!isNil {player getVariable "BIS_SUPP_request"} && {(player getVariable "BIS_SUPP_request") #0 == "CAS_Bombing"} && {!isnull (player getVariable "BIS_SUPP_selectedProvider")}}; private _pilot = player getVariable "BIS_SUPP_selectedProvider"; private _veh = vehicle _pilot; private _trts = (_veh WeaponsTurret [-1]) select { getText (configfile >> "CfgWeapons" >> _x >> "nameSound") == "cannon"}; private _cooldown = time - (_this getVariable ["BIS_SUPP_lastCall",time -122]) - ((_this getVariable ["BIS_SUPP_cooldown",0]) max 60); BIS_SUPP_commMenu = BIS_SUPP_commMenu + [ [ ["Gun run request",["No pilot cannon!",format ["wait for %1 sec",-(round _cooldown)]] select (_cooldown < 0)] select (count _trts == 0 or _cooldown <0), [4], "", -5, [[ "expression","GUNRUNCAS = true; [] spawn MGI_CAS; player setVariable ['BIS_SUPP_ammoType', 0]" ]], "1", ["1","0"] select (count _trts == 0 or _cooldown < 0), "\A3\ui_f\data\IGUI\Cfg\WeaponCursors\cannon_gs.paa" ] ]; uiSleep 0.1; showCommandingMenu "#USER:BIS_SUPP_commMenu"; waitUntil {uiSleep 0.2; isNil {player getVariable "BIS_SUPP_selectedProvider"} or {!isNil {player getVariable "BIS_SUPP_selectedProvider"} && isnull (player getVariable "BIS_SUPP_selectedProvider")}}; }; }; Seems to be short? It took me a lot of hours to find this solution. Feel free to test, comment, ask for some implementation. Pierre