In battle: Accuracy
The game determines attack accuracy right before it says "X used attack", if the attack does damage. If the attack does not do damage, the game determines it after it says "X used attack".
When the game rolls for attack accuracy, the game will cycle the RNG 3 times on that frame.
In battle: Critical hits
aaaaxxxx Attack hit: aaaa mod 100 < acc% otherwise miss
The game determines critical hits a few frames after the message "X used attack", provided that the attack does damage, and the attack did not miss, and it is not a tutorial battle where the game forbids critical hits.
When the game rolls for critical hits, the game will cycle the RNG 3 times on that frame.
xxxaxxxx Critical hit: a==0
This assumes a 1/16 chance of a critical hit. It does not describe situations where the critical hit ratio is raised to be greater than 1/16, or the target has the ability Battle Armor (no critical hits).
In battle: Damage variation
For almost all attacks, the amount of damage that an attack does varies between about 85% and 100%. The game determines damage variation three frames after it checks for critical hit.
When the game rolls for damage variation, the game will cycle the RNG 3 times on that frame.
xxxaxxxx Damage variation, max: a==0 min: a==15
The lower the number, the more damage the attack does.
It is not known for certain if 0000 is the only value that does max damage (a property in the first two generations where only the "best" value yields max damage).