Advertisement
Guest User

RBY - Gen 1 misses explained (Partially)

a guest
Oct 15th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Ok, so here's the Gen 1 accuracy code. (More or less)
  3.  
  4. AccuracyCheck:
  5.     call BattleRandom     ; Generate a random number 0-255, store it in A
  6.     ld b, a               ; Because we can only do math on A we need to move this into B
  7.     ld a, [MoveAccuracy]  ; Load our move accuracy into A
  8.     sub b                 ; Subtract the random number from A (MoveAccuracy - BattleRandom)
  9.     jr nc, .MoveMiss      ; So, 1 byte can only store 255 maximum, or 0 minimum. So if we go over 255 OR under 0, Carry is On.
  10.                           ; If the Carry flag is OFF then the move misses.
  11.  
  12. What the above code means is, if we have 100% accuracy (255) and we generate 255 randomly then 255-255 is 0 and the Carry flag stays OFF meaning a 100% accurate move will MISS. So, to fix this we skip the miss check if the result is 0.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement