Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ok, so here's the Gen 1 accuracy code. (More or less)
- AccuracyCheck:
- call BattleRandom ; Generate a random number 0-255, store it in A
- ld b, a ; Because we can only do math on A we need to move this into B
- ld a, [MoveAccuracy] ; Load our move accuracy into A
- sub b ; Subtract the random number from A (MoveAccuracy - BattleRandom)
- 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.
- ; If the Carry flag is OFF then the move misses.
- 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