Double post, but I have to acknowledge that you are right and the decoy code activated itself for missiles fired at other planes of the group. Of course, it led to really cool effects of missiles banking hard away from their initial target to rush at a decoy fired a couple km away.
The other issue is that if you targeted 50 fighters and a destroyer, the capship-targeting torpedo would likely be fired at a fighter, and vice-versa.
In any case, I wrote an additional piece of code to pseudo-randomly select individual crafts in the selected target group and check whether they are of the appropriate attack class and within the correct range. It was a bit inspired by the code written a long time ago by, I think, the Star Trek mod team to do auto-repair on ally ships by scanning each ship and seeing whether it needed repairs.
EDIT 1: I will test this improved code during the week and check if it solves the CTD issue I have. Outside this issue, BTW, the code survived a stress-test with two groups of 150 flights of 3 planes each using missiles and decoys. I had around a thousand missiles and decoys fired before the CTD ended the game the very same way it ends it when a couple of flights fight each other.
It was lagging “a bit” at the time, but I had debug print options on giving me a log a MB large with the list of missiles, decoys and script steps being done.
EDIT 2: this new feature seems to be perfectly compatible with the AI script released on the other thread.
EDIT 3: I got the single target selection to work, which, by the way, leads to really cool BSG 2003 salvo missile launches. However, I still have this CTD bug I cannot isolate. It does happen even if the decoys are deactivated and is definitely linked to the missiles, but the log doesn’t say anything and even if I add print instruction between each and every script instruction, I simply learn that the crash takes place after the end of the custom code update for some missile and before another custom code can even begin. Strange and very annoying as it is the only real obstacle left for a release. The only clue at the moment is that the CTD takes place mostly at the same time, when the missiles’ shipID reach around 2,500. But it’s not it as my huge stress test reached 17,000 before the CTD, with a lot more launchers, of course.
You can see below the effects of the pseudo-random target selection algorithm for missiles:
EDIT 4: I rewrote the missile code (the new version is, BTW, fully commented and much cleaner to help people reverse-engineer and improve it as needed) as well as increased the time between code updates. It seems to have done the trick. Honestly, I have no clue what happened. I’ll do the same things for decoys and keep my fingers crossed.
EDIT 5: scratch this, it crashed pretty fast during a stress test with 200 fighters fighting it out.