• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

Pokecrystal help: every attack kills in one hit

356
Posts
5
Years
    • Seen today
    I have been working on a hack using Pokecrystal and have encoutered a strange bug. This bug first began after I swapped out the Pokemon constants with my new Pokedex. This took quite some time, as after swapping out all Pokemon, I needed to go through and remove references to all of the removed Pokemon so that the ROM would compile. I have done this type of hack before without issue, but this time, I got this bug after recompiling.

    The particular bug is that, when any Pokemon uses any damage dealing attack, it always reduces the opponent's HP to zero. I am confused, as I did not change anything related to damage calculation. The Pokemon's base stats are displayed correctly on the stats menu, as is the base power of the attacks, so I know that the stats are being read in properly, and aren't due to the new Pokemon not being assigned correctly or something like that.

    The only things I modified in the core.asm file were commenting out the checks for UNOWN and MAGIKARP, instead having the code fallthrough or jump to the label that is used for the case that the Pokemon is not one of the above cases. I did not modify the effectcommands.asm file, where the battle damage routine is located, at all.

    One difference in this hack, and a similar one I did previously without experiencing this bug, was that I removed many of the maps from the game via commenting them out. I am certain that I lined everything up properly, as all of my newly added maps load and connect properly. (These maps worked fine without this bug occurring prior to the Pokemon swap, so I am certain it is not due to the new maps).

    My question is if anyone knows about how something could effect the damage calculation, and what files could affect this if they were modified. It seems this error must be caused by some file modified to have a specific map contant or atteibute removed, but I'm not sure where to look. Any help would be greatly appreciated, thanks!
     

    miksy91

    Dark Energy is back in action! ;)
    1,480
    Posts
    15
    Years
  • I can't really help solving this problem directly. But have you used git for version control? If you have, have you committed changes you have done to your hack often, and pushed them to your remote repository which should be a fork of pokecrystal? If you have, you could try to backtrace the bug by taking a look at the contents of the commits (Github UI shows them nicely). You can also try to locally hard reset to some previous commit via git reset --hard [commit ID], build the rom file from that state and see if the bug is still being present. If the bug is present, try hard reseting to some earlier commit and build the rom file again. Ultimately, you want to find two consecutive commits where the bug is not being present, and where the bug is present. The technique is practically binary search, but you don't have to do it exactly as such: https://en.wikipedia.org/wiki/Binary_search_algorithm

    Once you find the game-breaking commit, you should go through its contents via Github UI, and rollback the game-breaking change of that commit. The bug / programming error should be easy to find if you have been committing new changes often. If you haven't, there will be lots more changes, and tracking down the bug this way won't be feasible.
     
    Last edited:
    356
    Posts
    5
    Years
    • Seen today
    Thanks for the advice! Unfortunately, I don't have a github account set up (could never figure out how to get it working lol), and am just building off of locally stored directories.

    At this point, I have been going back through any of the files I modified to remove references to removed map files to see if adding things back in will fix the bug. The trouble is that, since I had to modify so many files in order to get the ROM to compile, there's a lot of potential files that could be the issue. I am almost certain it has to due with removing the old maps and not the Pokemon, since I have done a full Pokedex changeout before, complete with commenting/removing all references to removed Pokemon constants, and never experienced a bug like this.

    If all else fails, I can always re-download a fresh Pokecrystal, do a dex swapout without editing map files to ensure the bug wasn't caused by that, then re-add my new maps to ensure compatibility, and go from there. I posted this help request here mainly in the hopes that someone more familiar with the disassembly would be able to point towards specific files that have to do with damage calculation that may not be obvious to me. Thanks for the help though!
     
    356
    Posts
    5
    Years
    • Seen today
    Well, I discovered the cause of the bug. Turns out I did edit effectcommands.asm, and overlooked it somehow. The error in particular came from editing the routines to check for stat buffs for Light Ball and Thick Club. Since the PIKACHU, CUBONE, and MAROWAK Pokemon constants had been removed, I needed to edit this check, and so I had commented out the routine, leaving only the terminating ret statement so that the function would just fallthrough. What I didn't know is that the ItemBoostMonSpecies routine called by these checks is used to load the stat in the proper register, and so by not running this routine, the stat was never being properly loaded.

    My fix was to have the routines called like normal, but comment out the 3 lines assigning the Pokemon and Item constants, and then in the ItemBoostMonSpecies routine, I commented out everything from the push hl statement near the beginning, all the way to the terminating ret. So if anyone else is a dumbass like me and gets this problem while swapping Pokemon constants, maybe this'll help.
     
    Back
    Top