Black / White Battle RNG
Somewhat borderline on the realm of what we should control, so I'll post pretty vaguely so as to document for future TAS abuse:
I do know the seed location, not posting unless we find out it doesn't control link battles (ie anything shady).
Seeded in the transition between challenged animation fade to black --> fade to battle
Most likely seeded via the SHA-1 hash like initial seeds.
Stored at a memory location and called as needed for Battle Calculations (note: not Trainer actions)
Calculations appear as if they are similar to how they were done in gen 3/4.
Instead of %100 they are probably *100 like BW's RNG.
Instead of "a", it is probably >>60.
It's still pretty early in the research phase, so these are just presumptions for future research.
So far I've been able to abuse (Critical) Captures, stat reductions, critical hits, and misses via seed freezing around seed=0, it's pretty easy.
BW Battle RNG p2
Speed determines who gets what random number calculation priority. (Ingame Battles).
If it does not require a random number for a particular aspect of a move, it will not consume a frame for that calculation.
If your move is a delayed attack move (Fly/Future Sight/Doom Desire), the game will not consume any frames until the turn it activates.
If the Pokemon is knocked out, no consumption of frames is used for reducing effects (like stat drops).
So far tested structure (speculation at bottom of post):
0 - Initial
1 - Hit (Accuracy)
2 - Critical
3 - Damage
4 - Secondary Effects (reducing, status, effect spore)
So far I have only tested psychic (ie one secondary effect).
More complex moves like Tri-Attack have yet to be tested.
Also untested is Moody
((SEED>>32)*100) >>32, == 0-99, cmp if < accuracy, hit.
((SEED>>32)*s) >>32, if 0 crit).
Stage - *#
1 - *16
2 - *8
3 - *4
4 - *3
5 - *2
((SEED>>32)*100)>>32 = 0-99, cmp if < drop%, reduce.
BW Battle RNG p3
A Pokemon cannot thaw if it has been flinched. The game will not say if the Pokemon flinches.
Only consumes one frame for your move:
((SEED>>32)*7)>>32 == (0-6)
0 - Atk
1 - Def
2 - Speed
3 - SpA
4 - SpD
5 - Accuracy
6 - Evasion
Only consumes one frame for both the boost and drop, at the end of the turn:
((SEED>>32)*7)>>32 == (0-6) [Boost]
Same #-Stat correlation.
Since it only consumes 1 for the entire thing, not sure on which is the drop.
Consumes two frames in between Critical and Damage. It always does both calcs.
((SEED>>32)*100)>>32 == (0-99), if (0-19) pass Inflict
((SEED>>32)*3 )>>32 == (0-2), if Inflict...
0 - Burn
1 - Paralyze
2 - Freeze
Consumes two frames after Damage, for Flinch and then Status.
((SEED>>32)*100)>>32 == (0-99), if (0-9), the Pokemon Flinches.
((SEED>>32)*100)>>32 == (0-99), if (0-9), the Pokemon receives Status.
Consumes one frame before it calculates move frames. If it fails, no move frames.
((SEED>>32)*100)>>32 == (0-99), if (0-19) thaw out.
BW Battle RNG p4
((SEED>>32)*3>>32)+1 = Sleep Counter (Turns Asleep)
Returns 0-2 value, +1 ==> (1-3) turns asleep.
Custom2: Custom1 >> 32
Custom3: Custom2 +1
For the move Spore, it calculates Hit and then Turns Asleep.
Confusion Duration -- not completely sure
((SEED>>32)*4>>32)+1 = Confused Counter (Turns Confused)
Returns 0-3 value, +2 ==> (1-4) turns confused.
Custom2: Custom1 >>32
Custom3: Custom2 +1
For the move Confuse Ray, it calculates Hit and then Turns Confused.
((SEED>>32)*100>>32) = Paralysis Check
If 0-24, Pokemon is Paralyzed for the Turn.
If 25-99, Pokemon can move for the Turn.
((SEED>>32)*100>>32) = Infatuation Check
If 0-49, Pokemon is Infatuated for the Turn.
If 50-99, Pokemon can move for the Turn.
((SEED>>32)*100>>32) = Confusion Check
If 0-49, Pokemon is Confused for the Turn, and receives recoil.
Inflict recoil damage with the next frame (damage).
If 50-99, Pokemon can move for the Turn.
(SEED>>32)*(2^p)>>32 = Protect Check
%p = protect counter, initially 0.
If 0, Pokemon succeeds in Protecting.
p = p+1
Else, Protect fails.
p = 0
Catching and Critical Capture
Depending on how you calculate CC and CV,
you will use different multiplications to the seed.
First it calculates if critical capture, then the shake/capture values.
If result < CV, pass check. Total of 4 for regular catch, 1 for CC.
Esc = ((SEED>>32)*0xFF), return 0-254.
If Esc < F, then pass run away.
BW Battle RNG p5
Quick Claw Activation
QC = ((SEED>>32)*100)>>32 == (0-99)
if QC < 20, Quick Claw will activate.
20% chance to activate.
The game will cycle the RNG to store this value regardless of whether or not the Quick Claw holder moves, only if the game requires RNG to be done (opponent move).
This means that if you use an item while holding quick claw, if it would have been successful it would still consume a frame at the start anyways.
SS = ((SEED>>32)*100)>>32 == (0-99)
if SS < 30, Shed Skin will cure the status.
This always occurs at the end of the turn.
Swipe Moves (Bullet Seed)
SC = ((SEED>>32) * 6)>>32 == (0-5)
01 - Hit 2 Times
23 - Hit 3 Times
4 - Hit 4 Times
5 - Hit 5 Times
Occurs after Accuracy.
Triple kick is just a repeated move and has accuracy/crit/damage for each.
ES = ((SEED>>32)*100)>>32 == (0-99)
if ES < 30, Effect Spore will activate.
Only happens after physical move contact.
It uses the same seed to calculate what status. IDK.
FB = ((SEED>>32)*100)>>32 == (0-99)
if FB < 10, Focus Band will activate.
BW Battle RNG p6
Damage Random Value / Damage Variation
R = ((SEED>>32)*16>>32 == (0-15)
Inversely related to 85-100,
whereas 0 --> 100% damage
and 15 --> 85% damage
This is not what the onsite article says about battle damage chances. Even though it was written for D/P, I find it difficult to believe this aspect of the article to be correct.
Gen 3's Damage Random Value was calculated as follows, which is documented by FractalFusion here.
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.