• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • It's time to vote for your favorite Pokémon Battle Revolution protagonist in our new weekly protagonist poll! Click here to cast your vote and let us know which PBR protagonist you like most.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Battle] [PokeRed] Fix the 1/255 accuracy glitch in PokeRed disassembly

  • 58
    Posts
    13
    Years
    • Seen Oct 12, 2024
    Long time no see ;)

    See, I an not so new to RBY compiling, but there is that one glitch that ticks me off. In Red, Blue and Yellow, there is a 1/255 chance that ANY move with 100% accuracy would fail, and I would like to know how to fix this in the PokeRed disassembly script. This is mainly just for a personal project, though. Could anyone help?
     
    Long time no see ;)

    See, I an not so new to RBY compiling, but there is that one glitch that ticks me off. In Red, Blue and Yellow, there is a 1/255 chance that ANY move with 100% accuracy would fail, and I would like to know how to fix this in the PokeRed disassembly script. This is mainly just for a personal project, though. Could anyone help?

    for this one you need to dig in the code in
    engine/battle/core.asm, specifically .doAccuracyCheck

    Code:
    .doAccuracyCheck
    ; if the random number generated is greater than or equal to the scaled accuracy, the move misses
    ; note that this means that even the highest accuracy is still just a 255/256 chance, not 100%
    	call BattleRandom
    	cp b
    	jr nc, .moveMissed
    	ret
    in order to fix it, you can do something like
    Code:
    .doAccuracyCheck
    ; if the random number generated is greater than or equal to the scaled accuracy, the move misses
    ; note that this means that even the highest accuracy is still just a 255/256 chance, not 100%
    	call BattleRandom
    	cp b
    	jr z, .move_hit
    	jr nc, .moveMissed
    .move_hit
    	ret
    where the problem was that if accuracy was 0xFF and the number generated was also 0xFF then the check would say that it missed because the carry flag wasn't reset (b would not be larger than the register a that the cp instruction compares to)
    so we then say that if the two numbers are equal, then make sure it hits instead
    every move thus gets essentially a 1/255 boost but at the same time it ensures that moves with full accuracy hit
     
    Back
    Top