Units currently get extra range if they're on a hill, but it would be nice if they got a damage bonus as well. See #4028.
The question is, what shape should the bonus take?
Here's one way to think about it. The damage should be something like the kinetic energy of the projectile when it lands. Of course the real picture is messy, but we can think of energy being conserved so it's the same as the energy when we shoot the projectile, which is the kinetic energy mv^2/2 plus the potential energy mgh, where h is the elevation difference between ourselves and the target. Compared to the case with no elevation bonus (h = 0), this is a ratio of 1 + 2gh/v^2.
So the damage multiplier formula should look like 1 + k * h, where k = 2g/v^2. Here's some values of k for g = 9.81 and various projectile speeds:
v k unit 37.5 0.0140 catapult 62.5 0.0050 javelin, slinger 75 0.0035 archer, tower 150 0.0009 bolt shooter
We could have the bonus depend on the speed of the projectile (so catapults would get a huge elevation bonus and bolt shooters would get a very little one), or we could simplify the situation and choose one value of k for all ranged units. I prefer the second approach.
I did some testing and I think I like k = 0.01. This has a nice english meaning too: an elevation bonus of 10m corresponds to a damage bonus of 10%. We can always change it later if it turns out to be too much (or too little).
Playing on the "Empire" map for example, small hills were 10-20m high, and a 10-20% bonus there seems reasonable. Blacksmith upgrades are 20% damage each, for comparison. Cliffs and huge hills were 30-40m, but I think that's fine too. Note that the bonus becomes a penalty for ranged units that have targets above them, e.g. a unit 20m below their target has a damage multiplier of 0.8. (I added a minimum value, 0.1, otherwise mountains over 100m tall would break the formula.) So there's a double effect for ranged vs ranged battles.
Here's the units that have an elevation bonus.
template_structure_defense_defense_tower.xml: <ElevationBonus>15</ElevationBonus> template_structure_defense_sentry_tower.xml: <ElevationBonus>9.0</ElevationBonus> template_unit_mechanical_siege_tower.xml: <ElevationBonus>10</ElevationBonus>
To get the multiplier for them, we just add this height (maybe "ElevationBonus" is a bad name? (D2016)) to the elevation difference before plugging it into the formula. Note that enemies attack the base of the towers, so the damage bonus is only in one direction.
However, for units standing on walls, the bonus goes both ways, since the units are actually ~10m higher (the exact number depends on the civ). (Units on walls also have an aura for +3 armor and +20 vision, and melee units can't attack them.)
The elevation difference uses the y-coordinate of current target position, i.e. where the missile lands.
To get the damage multplier, we multiply the elevation bonus by the attack bonus. The attack bonus seems to be for hard counters, which are pike/spears vs cav, hunted elephants vs cav, and mace hero alexander sword cav vs other heroes. That is, there's currently no ranged hard counters, so the attack bonus here should always be 1.
In #4028, the idea is to then remove the range bonus for units. I'm ambivalent about this at the moment (haven't thought about it enough or gone through the calculations carefully), but anyway it should be done in a separate patch.