@MI_Fred
Well done, only one thing i had to change:
The guns didn't stop firing, so i've changed your script
and included a firing round counter to be passed with
the exec statement.
MIF_FieldGunArty.sqs:
;==MIF_FieldGunArty v.0.5==;
;**original script by MI_Fred
;**additional changes by Chris Death
;**firing round counter added by passing a 4th segment with
;**the exec statement
;**[gun1,gun2,gun3,rounds] exec "MIF_FieldGunArty.sqs"
;**the following was added
;**_rmax (=rounds to fire)
;**_rcount (=counter to check actual firing round)
_gun1 = _this select 0
_gun2 = _this select 1
_gun3 = _this select 2
_guns = [_gun1,_gun2,_gun3]
_rmax = _this select 3
_gnr1 = (gunner _gun1)
_gnr2 = (gunner _gun2)
_gnr3 = (gunner _gun3)
_gnrs = [_gnr1,_gnr2,_gnr3]
_gmax = count _gnrs
_g = 0
_rcount = 0
{_x setCombatMode "RED"} forEach _gnrs
;--the aimpoint, 100 meters in front of middle gun, 30 meters above
_aimpoint = [(getPos _gun2 select 0)+100*(sin(getDir _gun2)),(getPos _gun2 select 1)+100*(cos(getDir _gun2)),(getPos _gun2 select 2)+30]
_ax = _aimpoint select 0
_ay = _aimpoint select 1
_az = _aimpoint select 2
;--makes all gunners watch a random point near the aimpoint
#aimloop
(_gnrs select _g) doWatch [(_ax)-5+(random 5*2),(_ay)-5+(random 5*2),(_az)-2+(random 2*2)]
~.1
_g = _g + 1
? _g == _gmax : goto "prefire"
goto "aimloop"
;--makes the vehicles fire their weapons
#prefire
_gmax = count _gnrs
_g = 0
~3
#fireloop
? ((_guns select _g) ammo (weapons (_guns select _g) select 0)) < 1 : _guns = _guns - [(_guns select _g)]
? (getDammage (_guns select _g)) >= 1 : _guns = _guns - [(_guns select _g)]
(_guns select _g) fire (weapons (_guns select _g) select 0)
~1
_g = _g + 1
? _g == _gmax : goto "reload"
goto "fireloop"
;--the reload
#reload
_rcount = _rcount + 1
? _rcount == _rmax : exit
~20
_g = 0
goto "aimloop"
~S~ CD