; We know who we are
_plane = _this select 0

; If we're dead, we can't launch flares
?(not alive (_plane select 0) ): goto "Exit"

; If the engine's off, we can't launch flares
?(not isengineon (_plane select 0) ): goto "Exit"

; But, who's the bad guy?
_enemy = _plane select 2

; And what did he fire?
_weaponname = _plane select 1

; Get the missile object that was launched at us
_missile = nearestobject [_enemy, _weaponname]

; Play the pips over the radio
(_plane select 0) vehicleradio "IncomingPips"

; Wait till the missile is within 350
@ _missile distance (_plane select 0) < 350

; Init the counter
_count =0

#LaunchLoop
drop["kouleSvetlo","","Billboard",0.05,6,[-2,1,.3],[-6-random 6,- random 2,0],0,1.8,1,0,[1],[[1,1,0.3,1]],[0,1],0,0,"\BWC_MIII\scr\smokes.sqs","",(_plane select 0)] 

drop["kouleSvetlo","","Billboard",0.05,6,[2,1,.3],[6+random 6,- random 2,0],0,1.8,1,0,[1],[[1,1,0.3,1]],[0,1],0,0,"\BWC_MIII\scr\smokes.sqs","",(_plane select 0)]

; Next please
_count = _count+1

; Each flare makes a noise
(_plane select 0) say "FLARE"

; Wait for the next one
~.1

; Drop five pairs
?(_count<5):goto "LaunchLoop"

#Exit
exit