This is a very small mod but with a very big potential effect.
Civ 4 actually includes functions for ranged combat, and the AI knows how to use it very well. It even limits ranged attacks to targets within line of sight - all the setup for a great tactical mod. However, the calculation for ranged attack damage results only in positive numbers; a ranged attack will never do zero damage. This means a mod like a WW2 mod is hard to make because even the smallest, tiniest infantry can destroy a tank from a distance in about 15 shots.
In this version (version 2) there are three tiny SDK changes:
How to add ranged attacks in Civ4UnitInfos:
Civ 4 actually includes functions for ranged combat, and the AI knows how to use it very well. It even limits ranged attacks to targets within line of sight - all the setup for a great tactical mod. However, the calculation for ranged attack damage results only in positive numbers; a ranged attack will never do zero damage. This means a mod like a WW2 mod is hard to make because even the smallest, tiniest infantry can destroy a tank from a distance in about 15 shots.
In this version (version 2) there are three tiny SDK changes:
- The base calculation for ranged combat damage now subtracts "RANGED_COMBAT_DAMAGE" (set in global defines) after figuring out the ratio between units. This means that a unit must have greater ranged strength than the enemy combat strength in order to damage them.
- In all strength calculations, hitpoints are now ignored. Damaging a Tiger tank that is already damaged is just as hard as damaging a full-health Tiger tank. (This should affect regular combat too, but I haven't checked yet.)
- (Note: the above does not affect the usual AI calculations for damage, so AI units will still think they have a great chance to beat damaged units outside ranged combat, even if they don't.)
- The AI for ranged combat was adjusted to use actual ranged combat damage instead of "AI attack odds", so the AI will not shoot at things it can't damage.
How to add ranged attacks in Civ4UnitInfos:
Spoiler :