PROBLEM SOLVED ! I think ...
In helicas you have the line :
#testalive
If Not(Alive (_heli Select _i)) Then {_tmpheli = _tmpheli - [_heli Select _i]; _tmphlist = _tmphlist - [_hlist Select _i]}
The problem is _tmphlist = _tmphlist - [_hlist Select _i]}
. Reason: upon examination, all members of '_tmphlist' are the same: something like ["_i","_i","_i" ...] and so on. The error occurs whenever one of the helicopters dies.
When you subtract [_hlist select _i] from _tmphlist, ofp removes All the elments, as they are all the same.
Therefore, you end up with
... (_hlist Select _i) ... |#| Error Zero Divisor
, as for this particular loop of "heli2" your _hlist is empty, []. (Doing a hint format ["%1",(_hlist Select _i) ]) confirms it is this that is causing the error zero divisor message
The _hlist is regenerated after the next #mainloop so you don't get repeated error messages.
Solution: Replace the code after #testalive with this code:
#testalive
_hlist = []
If Not(Alive (_heli Select _i)) Then {_tmpheli = _tmpheli - [_heli Select _i]}
_i = _i + 1
If (_i < _n) Then {Goto "testalive"}
_heli = +_tmpheli
"_hlist = _hlist + [""_i""] " foreach _heli
_hlist = +_tmphlist
_tmpheli = NIL
_n = Count _heli
;Don't need a CAS for only 1 helicopter
If (_n < 2) Then {Exit}
Hope that solves the problem.