I'm very sorry but I still don't like the battle-solutions. But I've got a suggestion...
First let's think about the problem.
Thoughts:
1. The dimensions of a single square are some 10km or even much more!
2. Bowman can hit units but no city defenses from a distance.
3. Defenders with the same or a higher range would shoot back if they are attacked
4. Heavy weapons can also destroy buildings
5. Planes can bombard city defense and units but for example artillery can only bombard city defense at the moment
My suggestion:
1. Decide if a unit can bombard <iCanBombard>0 or 1
2. If it can bombard give it a range <iBombardRange>0,1,2,... (squares)
3. If it can bombard define what can be damaged (like airbomb-missions)
a) <iCanBombardUnits>0 or 1 (1 for bowman, catapult...)
b) <iCanBombardPort>0 or 1 (1 for artillery, mobile artillery)
c) <iCanBombardCityDefense>0 or 1 (0 for bowman, 1 for catapult,...)
d) <iCanBombardBuildings>0 or 1 (1 for cannon, artillery, mobile artillery)
e) <iCanBombardFactories>0 or 1 (1 for cannon, artillery, mobile artillery)
4. Define a battle distance <iBattleDistance>0,1,2,3,4,...
example:
warrior, swordman... 0
bowman 1
longbow, crossbow, ballista, trebu 2
catapult 4
...
Hint:There should never be higher range and smaller battledistance!
What is it good for? The way of battle could be improved. There are two types of battle - bombard and attack
bombard
When a unit bombards for example a city there should be direct counterfire from the city if there is a unit in the city that:
can bombard <iCanBombard>1
has the needed range <iBombardRange>0,1,2,...
and has the same or a higher battledistance
The defender allways uses the best unit with this feature. If the attacker has the longer or the same battledistance he hits first. If the defender has the longer distance he hits first. The defender hits the bombarding unit, the attacker hits what he choosed. If he choosed "bombard units" he maybe hits the counterunit.
bombard examples
1) You want to bombard a city with a cannon and the defender only has bowman. You can do bombard without counterhit because the battledistance of the cannon is higher than the battledistance of the bowman. If you now bombard the city with a bowman yourself there will be counterfire because of the same range and battle distance. But because of the same battledistance you hit first (moment of surprise) and so your bombardment will take maximum effect.
(The effect of the counterhit and bombardment must depend on the health and the power of the units.)
2) You want to bombard a city with a catapult but the defender has a cannon. You can bombard but he hits your catapult first because of the longer battledistance. That means he hits the first catapults while they are going into position. So because of the damage to the catapult it will cause less damage to its aim.
attack
It doesn't matter who attacks. The defender is chosen as always. But now all other units of the defender with the same or a higher battledistance than the attacking unit will have one firststrikechance.
attack examples
1) There are three longbowman in a city and a longbowman will attack the city. Than the strongest longbowman of the defender will defend as always, but before he fights the other two longbowman have a firststrikechance against the attacking longbowman. The rest of the battle is done as usual.
2) There are a swordman and a bowman in the city and a longbowman is going to attack. Than there will be no firststrike from the bowman and the battle goes as usual.
What do think about this suggestion?
I forgot something.
BattleDistance doesn't depend on CanBombard.
example
The rifleman should have <iCanBombard>0 but <iBattleDistance> >0 (for example more than a bowman).
So he can't bombard, but he has a firststrikechance when defending for example against an attacking bowman!
So if a rifleman wants to attack a city with two bowman he can't bombard them. He has to attack. But because of his larger battledistance there will be no firststrikechance for the second bowman.
And so if a longbowman wants to attack a city with two rifleman he can bombard without being hurt. But if he attacks the city he will fight against the strongest rifleman and will be maybe hurt by a firststrike of the second rifleman.