User:Nescientist/Damage: Difference between revisions

ok, theeeere you go (whatever...); it's not exactly "roundoff error", it's multiple things
Tiddlywinks (talk | contribs)
m format
Line 22: Line 22:
* ''Badge'' is applied in Generation II only. It is 1.25 if the attacking Pokémon is controlled by the player and if the player has obtained the [[Badge]] corresponding to the used move's [[type]], and 1 otherwise.
* ''Badge'' is applied in Generation II only. It is 1.25 if the attacking Pokémon is controlled by the player and if the player has obtained the [[Badge]] corresponding to the used move's [[type]], and 1 otherwise.
* ''Critical'' is 1.5 for a [[critical hit]] from Generation VI onward, 2 for a critical hit in Generations II-V, and 1 otherwise.
* ''Critical'' is 1.5 for a [[critical hit]] from Generation VI onward, 2 for a critical hit in Generations II-V, and 1 otherwise.
<ul><li>
* ''random'' is a random factor between 0.85 and 1.00 (inclusive)
{| class="expandable" style="margin:auto; float:left"
:{| class="roundy" style="background:#{{White color}}; border: 3px solid #{{Red color}}"
|''random'' is a random factor between 0.85 and 1.00 (inclusive)
|-
|
{| class="roundy" style="margin:auto; background:#{{White color}}; border: 3px solid #{{Red color}}"
|-
|-
|'''Generation III onward'''
|'''Generation III onward'''
Line 35: Line 31:
|Random factor effectively between approximately 0.85 and 1.00: a multiplication by a random uniformly distributed integer between 217 and 255 (inclusive), followed by an integer division by 255.
|Random factor effectively between approximately 0.85 and 1.00: a multiplication by a random uniformly distributed integer between 217 and 255 (inclusive), followed by an integer division by 255.
|}
|}
|}</li></ul>
{{Left clear}}
* ''STAB'' is the [[same-type attack bonus]]. This is equal to 1.5 if the move's [[type]] matches any of the user's types, 2 if the user of the move additionally has {{a|Adaptability}}, and 1 if otherwise.
* ''STAB'' is the [[same-type attack bonus]]. This is equal to 1.5 if the move's [[type]] matches any of the user's types, 2 if the user of the move additionally has {{a|Adaptability}}, and 1 if otherwise.
* ''Type'' is the [[type effectiveness]]. This can be 0, 0.25, 0.5, 1, 2, or 4 depending on both the move's and defending Pokémon's [[type]]s.
* ''Type'' is the [[type effectiveness]]. This can be 0, 0.25, 0.5, 1, 2, or 4 depending on both the move's and defending Pokémon's [[type]]s.
* ''Burn'' is 0.5 (from Generation III onward) if the attacker is {{status|burned}}, its Ability is not {{a|Guts}}, and the used move is a [[physical move]] (other than {{m|Facade}} from [[Generation VI]] onward), and 1 otherwise.
* ''Burn'' is 0.5 (from Generation III onward) if the attacker is {{status|burned}}, its Ability is not {{a|Guts}}, and the used move is a [[physical move]] (other than {{m|Facade}} from [[Generation VI]] onward), and 1 otherwise.
<ul><li>
* ''other'' is 1 in most cases, and a different multiplier in special cases
{| class="expandable" style="margin:auto; float:left"
:{| class="roundy" style="background:#{{White color}}; border: 3px solid #{{Red color}}"
|''other'' is 1 in most cases, and a different multiplier in special cases
|-
|
{| class="roundy" style="margin:auto; background:#{{White color}}; border: 3px solid #{{Red color}}"
!Cause
!Cause
!Value
!Value
Line 203: Line 193:
|If the used move is a damaging Z-Move the target has {{m|protect}}ed against
|If the used move is a damaging Z-Move the target has {{m|protect}}ed against
|}
|}
|}</li></ul>
{{Left clear}}


During the calculation, any operations are carried out on integers internally, such that effectively each division is a [[wp:Rounding#Rounding_to_integer|truncated integer division]] (rounding towards zero, cutting off any decimals), and any decimals are cut off after each multiplication operation. If the calculation yields <code>0</code>, the move will deal 1 HP damage instead; however, in [[Generation]]s {{gen|I}} and {{gen|V}}, different behavior may occur due to apparent oversights:
During the calculation, any operations are carried out on integers internally, such that effectively each division is a [[wp:Rounding#Rounding_to_integer|truncated integer division]] (rounding towards zero, cutting off any decimals), and any decimals are cut off after each multiplication operation. If the calculation yields <code>0</code>, the move will deal 1 HP damage instead; however, in [[Generation]]s {{gen|I}} and {{gen|V}}, different behavior may occur due to apparent oversights:

Revision as of 19:36, 25 February 2017

Damage calculation

Except for moves that deal direct damage, the damage dealt when a Pokémon uses a damaging move depends on its level, its effective Attack or Special Attack stat, the opponent's effective Defense or Special Defense stat, and the move's effective power. In addition, various factors of damage modification may also affect the damage dealt.

More precisely, damage is calculated as a:File:DamageCalc.png Damage = \left(\frac{\left( \frac{2 \times Level}{5} + 2\right) \times Power \times A / D}{50} + 2\right) \times Modifier

where

and Modifier is

a:File:ModifierCalc.png Modifier = Targets \times Weather \times Badge \times Critical \times random \times STAB \times Type \times Burn \times other

where

  • Targets is 0.75 if the move has more than one target, and 1 otherwise.
  • Weather is 1.5 if a Water-type move is being used during rain or a Fire-type move during harsh sunlight, and 0.5 if a Water-type move is used during harsh sunlight or a Fire-type move during rain, and 1 otherwise.
  • Badge is applied in Generation II only. It is 1.25 if the attacking Pokémon is controlled by the player and if the player has obtained the Badge corresponding to the used move's type, and 1 otherwise.
  • Critical is 1.5 for a critical hit from Generation VI onward, 2 for a critical hit in Generations II-V, and 1 otherwise.
  • random is a random factor between 0.85 and 1.00 (inclusive)
Generation III onward Uniformly distributed random integer percentage between 0.85 and 1.00 (inclusive)
Generations I-II Random factor effectively between approximately 0.85 and 1.00: a multiplication by a random uniformly distributed integer between 217 and 255 (inclusive), followed by an integer division by 255.
  • STAB is the same-type attack bonus. This is equal to 1.5 if the move's type matches any of the user's types, 2 if the user of the move additionally has Adaptability, and 1 if otherwise.
  • Type is the type effectiveness. This can be 0, 0.25, 0.5, 1, 2, or 4 depending on both the move's and defending Pokémon's types.
  • Burn is 0.5 (from Generation III onward) if the attacker is burned, its Ability is not Guts, and the used move is a physical move (other than Facade from Generation VI onward), and 1 otherwise.
  • other is 1 in most cases, and a different multiplier in special cases
Cause Value Detail
Astonish 2 In Generation III only, if the used move, and the defender has previously used Minimize
Aurora Veil 0.5 * If set on the defender's side, the move is not a critical hit, and the user's Ability is not Infiltrator
Body Slam 2 From Generation VI onward, if the used move, and the defender has previously used Minimize
Bulldoze 0.5 If the used move, and the defender is affected by Grassy Terrain
Chilan Berry 0.5 If held by the defender, the move was Normal-type
Dragon Rush 2 From Generation VI onward, if the used move, and the defender has previously used Minimize
Earthquake 0.5 If the used move, and the defender is affected by Grassy Terrain
2 From Generation V onward, if the used move, and the defender is in the semi-invulnarable turn of Dig
Extrasensory 2 In Generation III only, if the used move, and the defender has previously used Minimize
Expert Belt ~1.2 If held by the attacker and the move was super effective (Type > 1)
Fluffy 0.5 If the defender has this Ability, and the used move makes contact and is not Fire-type
2 If the defender has this Ability, and the used move is Fire-type and does not make contact
Filter 1.5 If the defender has this Ability and the move was super effective (Type > 1)
Flying Press 2 If the used move, and the defender has previously used Minimize
Friend Guard 0.75 If an ally of the defender has this Ability
Heat Crash 2 From Generation VI onward, if the used move, and the defender has previously used Minimize
Heavy Slam 2 In Generation VII, if the used move, and the defender has previously used Minimize
Life Orb ~1.3 If held by the attacker
Light Screen 0.5 * Form Generation III onward, if set on the defender's side, the move used is special, not a critical hit, and the user's Ability is not Infiltrator
Magnitude 0.5 If the used move, and defender is affected by Grassy Terrain
2 From Generation V onward, if the used move, and the defender is in the semi-invulnarable turn of Dig
Multiscale 0.5 If the defender has this Ability and is at full health
Misty Terrain 0.5 If the defender is affected by it, and the used move is Dragon-type
Needle Arm 2 In Generation III only, if the used move, and the defender has previously used Minimize
Metronome >1 1 + (~20% per successfully used successive move) if held by the attacker, but no more than 2
Phantom Force 2 If the used move, and the defender has previously used Minimize
Reflect 0.5 * From Generation III onward, if set on the defender's side, the move used is physical, not a critical hit, and the user's Ability is not Infiltrator
Shadow Force 2 If the used move, and the defender has previously used Minimize
Shadow Shield 0.5 If the defender has this Ability and is at full health
Sniper 1.5 If the attacker has this Ability and the move was a critical hit
Solid Rock 1.5 If the defender has this Ability and the move was super effective (Type > 1)
Stakeout 2 If the attacker has this Ability and the target has switched in
Steamroller 2 If the used move, and the defender has previously used Minimize
Stomp 2 In Generation III and from Generation V onward, if the used move, and the defender has previously used Minimize
Surf 2 From Generation V onward, if the used move, and the defender is in the semi-invulnarable turn of Dive
Tinted Lens 2 If the attacker has this Ability and the move was not very effective (Type < 1)
Type-resist Berries 0.5 If held by the defender, the move was of the resisted type and super effective
Whirlpool 2 From Generation V onward, If the used move, and the defender is in the semi-invulnarable turn of Dive
Z-Moves 0.25 If the used move is a damaging Z-Move the target has protected against

During the calculation, any operations are carried out on integers internally, such that effectively each division is a truncated integer division (rounding towards zero, cutting off any decimals), and any decimals are cut off after each multiplication operation. If the calculation yields 0, the move will deal 1 HP damage instead; however, in Generations I and V, different behavior may occur due to apparent oversights:

  • In Generation I, if the calculation yields 0 because the target has two types that both resist the move's type, the move will miss as if it was ineffective;
  • In Generation V, a move may deal 0 HP damage when other is less than 1, because the routine to prevent 0 HP damage is erroneously performed before applying the other factor.

Example

Imagine a level 75 Glaceon that does not suffer a burn and holds no item with an effective Attack stat of 123 uses Ice Fang (an Ice-type physical move with a power of 65) against a Garchomp with an effective Defense stat of 163 in Generation VI, and does not land a critical hit. Then, the move will receive STAB, because Glaceon's Ice type matches the move's: STAB = 1.5. Additionally, Garchomp is Dragon/Ground, and therefore has a double weakness to the move's ice type: Type = 4. All other (non-random) factors of Modifier will be 1. This effectively gives

a:File:ModifierCalcExample.png Modifier = 1 \times 1 \times 1 \times 1 \times (rand \in [0.85,1.00]) \times 1.5 \times 4 \times 1 \times 1 = rand \in [5.10,6.00]

When also plugging in Glaceon's effective Attacks stat and Garchomp's effective Defense stat, the whole damage formula gives

a:File:DamageCalcExample1.png Damage = \left(\frac{\left( \frac{2 \times 75}{5} + 2\right) \times 65 \times 123 / 163}{50} + 2\right) \times Modifier

a:File:DamageCalcExample2.png = rand \in [168,196]

That means Ice Fang will do between 168 and 198 HP damage, depending on luck.

If the same Glaceon holds a Muscle Band and its Ice Fang lands a critical hit against Garchomp, it will be Critical = 1.5, effectively giving

a:File:ModifierCalcExample2.png Modifier = 1 \times 1 \times 1 \times 1.5 \times (rand \in [0.85,1.00]) \times 1.5 \times 4 \times 1 \times 1 = rand \in [7.65,9.00]

Furthermore, Ice Fang's effective power will be boosted by the Muscle Band by (approximately) 10% to become 71, leading the whole formula to give

a:File:DamageCalcExample3.png Damage = \left(\frac{\left( \frac{2 \times 75}{5} + 2\right) \times 71 \times 123 / 163}{50} + 2\right) \times Modifier

a:File:DamageCalcExample4.png = rand \in [268,324]

That means Ice Fang will now do between 268 and 324 HP damage, depending on luck.