Gen 4 and Gen 5:
1) In Gen 4, the chance of protecting succeeding does not fall below
1/8, which has now been corrected in this commit. Previously, the
chance of success in Gen 4 was allowed to drop all the way to
1/(2**32) as in Gen 5.
Please see upokecenter for the correct mechanics:
http://upokecenter.dreamhosters.com/dex/?lang=en&move=182
For Protect and friends, Smogon currently says that the chance of
success does not fall below 50%, which is inconsistent both with the
current Pokemon Showdown! behaviour and with upokecenter. It is
pretty much certain that upokecenter is accurate here, since it is
based directly on the in-game data. This commit implements the
upokecenter mechanics.
2) This commit also consolidates some duplicate code with Protect and
friends by moving the miss chance logic to an event of the 'stall'
volatile called onStallMove. This allows me to remove some duplicate
code from moves.js.
3) Currently, some but not all of Protect and friends have a flag
called stallingMove set to true. This flag does not appear to be used
for anything. However, for consistency, I have set it to true for all
the "stall moves", as opposed to just a subset of them.
- Outrage is supposed to be able to confuse while asleep, as long as the duration would have ended the turn of attempted use anyway, much like Protect + Outrage. Also this breaks the game.
Two-turn moves are now controlled by a volatile, twoturnmove, which determines whether a Pokemon executes the charge turn or the move turn of a two-turn move. This handles mechanics like Truant Pokemon being unable to use two-turn moves, as the execution turn is their truancy turn. It also handles various edge cases involving moves that call other moves (e.g. Metronome) and Encore.
These changes add a new event, onChargeMove, in which one can return false to "skip" the charging turn and execute the move in full immediately. For example, Solarbeam returns false in onChargeMove if the weather is sunny, and Power Herb returns false if the Pokemon uses its item successfully. (Actually, those are the only two examples at present.)
This implementation is complete except for one issue, an inversion of a previous problem: whereas before, moves like Assist calling two-turn moves would execute them immediately, now, only the charge turn will be executed, and the Pokemon will not be locked into the move. This is due to be fixed soon.