Advertisement
DaWoblefet

You can't prove Speed modifiers are chained

Aug 10th, 2019
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. Proof that it is mathematically impossible to demonstrate on cartridge that Speed modifiers are chained
  2.  
  3.  
  4. Stats are represented in Pokemon with 16 bits. As a result, the maximum possible stat capable of being stored is 0xFFFF (65535 in decimal). Of course, you can't get this high without hacking.
  5.  
  6. When non-HP stats have modifiers applied to them, they start off with boosts/drops (+6 to -6). When applying these boosts/drops, the game multiplies using a 16-bit context. That is, if the initial Speed stat times the numerator of the multiplier is greater than 65535, it will only consider the 16 least significant bits in its calculation, as a result effectively doing a modulo 65536. Here are the Speed modifiers:
  7.  
  8. +6 - 8/2
  9. +5 - 7/2
  10. +4 - 6/2
  11. +3 - 5/2
  12. +2 - 4/2
  13. +1 - 3/2
  14. +0 - 2/2
  15. -1 - 2/3
  16. -2 - 2/4
  17. -3 - 2/5
  18. -4 - 2/6
  19. -5 - 2/7
  20. -6 - 2/8
  21.  
  22. So a Pokemon with 32768 Speed with +0 Speed boost/drop will multiply 32768 times 2, reach 65536, overflow to 0, and divide by 2 to become 0. Therefore, the largest Speed stat possible because of this 16-bit context is going to be initially 32767 (32767 * 2 = 65534, divided by 2 = 32767).
  23.  
  24. It is also known that the following Speed modifiers are applied together, then pokeRounded.
  25. Tailwind (2x)
  26. Chlorophyll / Swift Swim / Sand Rush / Slush Rush (2x)
  27. Surge Surfer (2x)
  28. Unburden (2x)
  29. Quick Feet (ignores para Speed drop) (1.5x)
  30. Slow Start (0.5x)
  31. Iron Ball / Power Items (0.5x)
  32. Choice Scarf (1.5x)
  33. Quick Powder (2x if Ditto and not Transformed)
  34. Pledge swamp (0.25x)
  35.  
  36.  
  37. We also know the the context for multiplying Speed modifiers during the pokeRound is not a 16-bit context. Otherwise, something like Tailwind with 100 Speed would become 8 Speed, which is surely wrong. In fact, even if no Speed modifiers were present, the game would still implicitly apply a modifier of 4096/4096, so ANY Speed stat greater than 15 would undergo 16-bit overflow, which is definitely wrong.
  38.  
  39. The most Speed modifiers applicable at once are Tailwind, a 2x Speed ability like Surge Surfer, and Quick Powder. If these were chained together, the final modifier would be 32768. But doing pokeRound (32767 * 32768 / 4096) won't overflow in a 32-bit context even with just the multiplication alone.
  40.  
  41. Moreover, you can't prove modifiers are chained because of rounding within the Speed modifiers, because if you represent Speed modifiers as properly being scaled to /4096, you will NEVER encounter any situations where rounding is needed.
  42.  
  43. As a result, though it is highly likely the game follows the pattern of how Attack/Defense modifiers are applied, nevertheless it is not proveable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement