Hello,
okay, I will tell you what I think, so you can try to make some fixes yourself, and possibly solve the issue, you know your code and style better.
So, for first, line which catched me:
acter.lock=random(0, opar.length-1);
this is in turn procedure of ai scrypt. Problem is, that if lock means pointer to the target, It can not be assigned by this way. Lock is integer, so if you choose random number from length of array with selected good / evil ships, and assign it to aircraft's lock, you will gave incorrect result, because position in opar temporary array has nothing in common with position in ships array, so you can get correct result as well as incorrect, depends on order of good and evil ships and selected number.
I created two loops, because there is also second line of this type, and with them ai seems to work right, hovever with errors in some times, which cause I searching for.
What you think about this?
Hope this helps.
Best regards
Rastislav