I won't just explain the combat equation here, but also analyze it. But first, the explanation.
Damage = Basic damage - armor + pierce damage Basic damage can be blocked by armor while pierce damage cannot. The maximum damage is always at least as large as the pierce damage, though. The actual damage is now calculated like this:
Damage = [1 .. 2] * (maximum damage/2), being dependent from a random variable. The damage is always rounded up.
A more scientific notation goes like this: ceiling[(max. damage)/2] <= damage <= 2*ceiling[(max. damage)/2]
To get the average damage, multiply the maximum damage with 0.75.
A level 1 grunt has 2 armor, and the damage is 2 - 9. The pierce damage for a non-upgraded grunt is 3; the total damage can go up to 9, thus the basic damage is 6. Our equation becomes:
Level 1 grunt damage = 6 - armor + 3, always at least 3.
Now suppose our grunt is facing a level 1 footman. Only 4 points of the basic damage go through the armor, the rest is absorbed. Thus, the maximum damage becomes 7. Now a random value is applied to the damage which will be rounded up afterwards. The actual damage will be between 4 and 8. Against a helpless unarmored peon, the damage lies between 5 and 10, against buildings which have an armor of 20, the damage will never exceed 3.
The upgrades do not raise the pierce damage for knights and grunts, unlike what many players think. The fact that a mage kills buildings faster than knights proves this. You will read something different at Blizzard's page, but just run a test with a knight. A knight kills a building in the same time regardless of the fact whether he is upgraded or not. However, a fully upgraded ranger has a pierce damage of 11! For these, the pierce damage is affected by upgrades.
Now let's go to the practice:
A level 5 grunt has 2+4 armor, and the damage is 2 - 9 +4. The pierce damage for a non-upgraded grunt is 3; the basic damage is 6. The basic damage is increased by the upgrades, becoming 10. The armor is 6. Our equation becomes:
Level 5 grunt damage = 10 - armor + 3, always at least 3.
A level 1 knight has 4 armor, the damage is 2 - 12, 4 pierce damage and 8 basic damage. Our grunt has 60 hit points while the knight has 90. Who wins the battle?
Level 1 knight damage = 8 - armor + 4, always at least 4.
The grunt's upgraded armor will absorb most of the knight's basic damage and suffer up to 6 damage per hit. The knight's crappy armor cannot absorb the grunt's basic damage, and because the grunt has such a high basic damage, the knight will get up to 9 damage per hit! Theoretically, a level 5 grunt and a level 1 knight will kill each other. However, because the rounding is in favor of our grunt,
a level 5 grunt will kill a level 1 knight!
Proof: whow, this sounds like at school :-) The grunt will inflict 5 to 10 damage per hit, the knight 3 to 6, the averages being 7.5 and 4.5. After 12 hits from the grunt, the knight is history. The grunt will have 60 - 12 * 4.5 = 6 hit points left (in the average case). Of course, the knight wins sometimes (if having the first strike), but the grunt has better chances to survive.
I'm assuming all units have level 5, which is the only reasonable level for knights and orcs. Bloodlust doubles both basic and pierce damage. Now what will be the consequences? A level 5 ogre does 2 - 12 +4 damage. Applying the combat equation against a level 5 knight, the resulting maximum damage is 8-4 +4 = 8. Now let's bloodlust our ogre: his stats are now 4 - 24 +8, 16 basic damage and 8 pierce damage. The poor knight now suffers 16-4 + 8 = 24 damage per hit (all values are maximum damage). Thus, bloodlusted ogres do three times the damage making them the most feared (and most dim-witted) killing machines that the horde ever had.
What are the consequences of bloodlust? Two knights deal 12 damage per attack (average) to the ogre who kills a knight with 5 hits (18 damage per hit in the average case). The ogre will have 30 hit points left. One knight deals 6 damage per hit to the ogre, killing him after 5 hits. However, the knight will be gone, too, after five hits! This means that a human player loses against bloodlusted ogres even if he has twice as many knights! Even though the equation is very fragile (if the first knight survives the ogre's fifth hit, the knights will win) and the chance of the ogre is less than 50 % in a 2 vs 1 fight, the ogres will win a real battle if the numbers are just a bit larger. Because a battle involves running around, the ogres (being packed in a smaller group and able to attack the same target together) will crush the knights even if they are outnumbered by twice as many foes. That's why human players lose against bloodlust unless they are skilled in magic.
Not only the strength, but also the speed of the attack matters. The reload times for the units vary much. Here is a listing of the reload times in program cycles:
|peon, grunt, ogre||25|
|cannon & guard tower||150|
Of course human and orc units have the same reload times. You can draw some very interesting conclusions from this statistic:
A level 5 knight attacking a building with 20 armor has 4 pierce damage that will get through. A ballista has 0 pierce damage and 80 basic damage, thus the maximum damage will be 60. However, a knight attacks 8 times faster than a ballista. He deals 32 damage to a building during the time when the ballista does 60 (75 when upgraded once). However, you can train two (almost three) knights in the time when you train a catapult. That's why good players rarely use catapults except against towers. Catapults are slow, don't deal much damage (compared to the cost) and are useless in melee fights. Their only advantage is their high range. And as soon as mages enter the board, the catapults are no longer needed. However, if you upgrade (to level 2) and protect your cats, they have a great firepower, so not only if you play humans and cannot use bloodlust, they are worth their money if you control them well. Thanks to Shlonglor for reminding me.
The archer deals 2 - 9 +5 damage per shot (3 basic damage and 6+5 pierce damage. The dragon has 5 armor, reducing the maximum damage to 12 (9 average). A dragon has 16 pierce damage that will all go through the archer's skin. The average damage is 12, but it is applied twice per attack. Our ranger will die after being roasted three times in the dragon fire (unless he is very unlucky). Because the ranger can attack about nine times, he deals 81 damage to the dragon. Therefore, two rangers or one ranger and a paladin with healing and full mana can kill a dragon. Now compare their cost ...
That's why you should always haste and bloodlust your dragons, making them deliver four times the pain! It's like Quad Damage in Quake :-) Even then, a few mages with polymorph or blizzard and slow will make your dragon attack look poor. By the way, many players assume that dragons become three times stronger after bloodlust (like ogres). This is wrong, because dragons have sixteen pierce damage that will simply be doubled, and no additional basic damage that will penetrate the armor after being doubled.
Buildings have an armor of 20, so for knights, only their pierce damage matters. Within 200 program cycles, a knight can attack 8 times, with 3 points of average damage, for a total of 24 damage points. Mages and Death Knights have 9 pierce damage. They attack more slowly though, only 5 times within 200 program cycles, with 7.5 points of average damage, making a total of 37.5 points. That's more than 50 % better than the knight! Now you know why good players use mages to finish off buildings once their mana is used. (By the way, bloodlust does not change this fact. So bloodlust your DKs once you have defeated the enemy troops, not your ogres.)
Now what are you supposed to do with all those numbers? Nothing? Well, I have learned Warcraft intuitively, as all other players I know have. However, if you ask yourself why some good players prefer a particular unit and avoid others, take a closer look at the numbers! But always keep in mind that Warcraft is not chess. You should never calculate the damage of a unit during a game or you'll have much to think about soon :-)