I appreciate that you try to help but I think there are no good reasons for such bad auto defense fire code. 
Two simple lines of code could have fixed the problem I described. 
Code:
if (not_yet_fired == true and distance_to_enemy == 1)
    do_fire();
I do understand it may be a bit more complicated but certainly I can write a working code in a few hours.
Me and my friend are not into small scenarios and we had a blast and loved playing the Quate Bras & Ligny campaign scenario until it was obvious that the defensive fire routine is broken and we can't go on. 
I hope they can fix the AI code for this but I'm surprised it hadn't been reported since 2014.