what is if the range attack is better then the melee and what is if there are 2 range ( one with range 3 and one with 9 for example ) and one melee?
well, im not too sure.....i cant solve everything....
The solution would be modder defined priorities. Have a
<priority value="1" /> tag in the attack skill, where lower numbers (1 = first priority) would be used over higher numbers. So if there are two ranged skills, one priority 1, and the other priority 2, it will always use the priority 1 until it cannot anymore. If it can't use priority one, but can use priority two (let's say 1 is a ranged attack that has a minimum range, and 2 is dropping a rock, which has no minimum range, but can't fire as far). Finally, when right up to the foe, use the melee attack. Obviously the CPU will not be perfect, a human player may decide to force the use of the range attack on a different unit, based on the situation.