You are on Pokemon Online, trying to give your Dusclops good defensive effort values (EVs). You decide to use all of your EVs to boost its defenses, so you have 510 effort values to work with. You notice that Dusclops has 130 base Defense and 130 base Special Defense, so you put 252 EVs in Defense, 252 EVs in Special Defense and the remaining 6 EVs in HP. You then realize that you can give Dusclops a nature that boosts either its Defense or Special Defense. So now its defenses aren't equal, and… you start to wonder if your previous EV distribution was such a good idea after all...
Or suppose you want to make your Salamence be able to take hits a little better. You can reserve 80 EVs, say, for this purpose, and you're trying to distribute them to Salamence's defenses in the best way possible. So, you look at Salamence's stats. It has 95 base HP, 80 base Defense and 80 base Special Defense. You notice Salamence's Intimidate trait, so you decide that Salamence can already take physical hits moderately well, and hence you put the 80 EVs in Special Defense. However, you start to wonder if this decision is justified. Maybe putting them in HP would have been better...
If the above conforms to what you usually think about when trying to find good defensive EVs for your Pokemon, and want to start building the best defensive Pokemon given the EVs you have left, continue reading.
To understand how to distribute your defensive EVs, it is important to understand what the Overall Harm that a Pokemon can sustain is.
The Overall Harm is a number representing the fraction of HP a Pokemon would lose if it was to be dealt a physical move and a special move of the same power in succession. It is defined using the following formula:
Overall Harm = (k(D + IS) + 4DS) ÷ HDS
Thus, to distribute your EVs for maximum defenses, you need to choose H, D and S in the above formula such that the Overall Harm is the lowest possible.
The DefenseEffortValues applet uses the formula for the Overall Harm displayed above, and cycles through all possible EV distributions to give you the one that provides you with the lowest possible Overall Harm. (The value for k used in the applet is 20000. You can read later for an explanation of the choice of this value.) It can be accessed here.
For the Dusclops example written in the introduction, the applet tells us to put 252 EVs in HP, 160 EVs in Defense and 88 EVs in Special Defense, with a nature that boosts Special Defense. The stats would then be 284 HP, 336 Defense and 352 Special Defense.
For the Salamence example, assuming it has an Adamant Nature, the applet tells us to put 60 EVs in HP and 20 EVs in Special Defense for the best overall defense. This gives us a 346 HP stat, 196 Defense stat and 201 Special Defense stat.
You may skip all the following sections if you're not interested in how the formula for the overall harm was obtained.
To be able to understand how the Overall Harm formula was found, we first need to know how the game actually calculates the damage that your Pokemon is dealt. This is done by the so-called Damage Formula, which can be written in the following manner:
Damage = ((Harm Dealt) ÷ (Your Defense)) + 2) × TypeModifiers × RandomNumber
(Harm Dealt is equal to 42 × Foe's Attack × Move Base Power ÷ 50 if the foe is a Level 100 Pokemon.) We need to find out what happens to the damage dealt if the same Pokemon uses the same move over and over, and you increase or decrease your Defense (or Special Defense) stat. Because of this, the foe's Attack stat and move Base Power is kept constant throughout, and so are the Type Modifiers. We assume that the random number generated is always the maximum, too, so the damage formula becomes:
Damage = (k ÷ D) + 2
where k is the constant damage that the foe is dealing, and D is your defense stat.
We now need to factor your HP in the calculation. If 60 damage is dealt to a Pokemon with 300 HP, it will lose 1/5 of its total HP, whereas 60 damage dealt to a Pokemon with 480 HP will only make it lose 1/8 of its total HP. Here, we see why the HP stat is also important. Hence, we can conclude that
Physical Damage as a Fraction of HP = ((k ÷ D) + 2) ÷ H
where H is your HP stat. Rearranging, we get
Physical Damage as a Fraction of HP = (k + 2D) ÷ HD
Special Damage as a Fraction of HP = (k + 2S) ÷ HS
where S is your Special Defense stat. Adding the above two formulas together and rearranging the formula, we get the Overall Harm that the Pokemon will take as a fraction of its HP:
Overall Harm = ((k + 2D) ÷ HD) + ((k + 2S) ÷ HS) = (S(k + 2D) + D(k + 2S)) ÷ HDS = (kS + 2DS + kD + 2DS) ÷ HDS = (k(D + S) + 4DS) ÷ HDS Overall Harm = (k(D + S) + 4DS) ÷ HDS
All that remains is to choose a suitable value of k. This can be basically any number that you can dream of. However, higher values of k produce better values (otherwise the value for the Overall Harm would be too small). 20000 seems to be a good all-round value. (Incidentally, it's very near the value generated when a Level 100 Pokemon with 317 Attack stat uses a 75 Base Power move).
Sometimes, you don't need your Pokemon to take hits equally well from both physical attacks and special attacks. Maybe you prefer your Pokemon to take hits better from the physical side, or from the special side. This is where the Biased Overall Harm comes in.
First, we introduce a bias factor B. B is a number between 0 and 1 inclusive, which provides the degree of bias you want from the physical side. B=0 would make the Overall Harm formula take care of the special side exclusively; B=1 would make the formula take care of only the physical side; B=0.5 would make the Overall Harm formula take care of both equally (as it is right now). Of course, B can take any value you like between 0 and 1, which gives you varying degrees of bias.
Let's see how we are going to incorporate this number in the Overall Harm formula now.
First of all, we rewrite the Overall Harm formula as follows:
Overall Harm = [(k + 2D) ÷ HD] + [(k + 2S) ÷ HS]
Recall that the first pair of square brackets is the damage you take from a physical hit, and the second pair of square brackets is the damage you take from a special hit of the same power. We now need to vary this damage according to the value of B. Here is how it's done:
Biased Overall Harm = (2B)[(k + 2D) ÷ HD] + (2 – 2B)[(k + 2S) ÷ HS]
Let's see what happens when B = 1:
Biased Overall Harm = (2(1))[(k + 2D) ÷ HD] + (2 – 2(1))[(k + 2S) ÷ HS] = 2[(k + 2D) ÷ HD] + 0[(k + 2S) ÷ HS] = 2[(k + 2D) ÷ HD]
So, when B = 1, the Overall Harm formula returns the damage from two physical hits, and so the formula will exclusively raise the Defense stat to try to lower the overall damage harm as much as possible.
When B = 0:
Biased Overall Harm = (2(0))[(k + 2D) ÷ HD] + (2 – 2(0))[(k + 2S) ÷ HS] = 0[(k + 2D) ÷ HD] + 2[(k + 2S) ÷ HS] = 2[(k + 2S) ÷ HS]
This returned the damage from two special hits, and so the formula would try to increase the Special Defense stat as much as possible in this case.
And when B = 0.5:
Biased Overall Harm = (2(0.5))[(k + 2D) ÷ HD] + (2 – 2(0.5))[(k + 2S) ÷ HS] = 1[(k + 2D) ÷ HD] + 1[(k + 2S) ÷ HS] = [(k + 2D) ÷ HD] + [(k + 2S) ÷ HS]
This returned the usual, unbiased, Overall Harm formula we wrote before, as it should have done.
Sometimes, you raise your defenses during the match, either via moves, via items or via traits.
The item Soul Dew makes the Special Defense stat of Latios and Latias 1.5 times of what it was before. The item Metal Powder makes both the Defense and Special Defense of Ditto 1.5 times of what they were before.
The ability Marvel Scale makes the Defense of Milotic 1.5 times of what it was before if it is afflicted by a status condition.
The effect of these things in the Overall Harm formula is very minor: you just replace D and S, if necessary, by the modified Defense and/or Special Defense stats.
When a Pokemon with the Intimidate ability switches into the foe, it makes the opponent's physical attack stat 2/3 of what it was before. This means that, in the above formula, the physical damage as a fraction of HP would be
Physical Damage as a Fraction of HP = ((2/3)k + 2D) ÷ HD
The special damage as a fraction of HP would still be the same. Hence, overall,
Overall Harm = (((2/3)k + 2D) ÷ HD) + ((k + 2S) ÷ HS) = (S((2/3)k + 2D) + D(k + 2S)) ÷ HDS = ((2/3)kS + 2DS + kD + 2DS) ÷ HDS = (k(D + (2/3)S) + 4DS) ÷ HDS Overall Harm for Pokemon with Intimidate = (k(D + (2/3)S) + 4DS) ÷ HDS
Of course, this will hold for as long as the foe stays Intimidated.
A Pokemon with Leftovers recovers 1/16 of its HP at the end of each turn. Thus, at the end of the turn, the physical and special damage as a fraction of HP will both be 1/16 less, and hence
Overall Harm = ((k + 2D) ÷ HD – 1/16) + ((k + 2S) ÷ HS – 1/16) = ((k + 2D) ÷ HD) + ((k + 2S) ÷ HS) – (1/16 + 1/16) = ((k(D + S) + 4DS) ÷ HDS) – 1/8 Overall Harm for Pokemon with Leftovers = Overall Harm – 0.125
This means that attaching Leftovers to a Pokemon will not affect the way you distribute your defensive EVs to guarantee the maximum defenses possible. This is why the Leftovers item is not mentioned anywhere in the formula.