• 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.

[Scripting Question] Pokemon Base Stats

  • 4
    Posts
    5
    Years
    • Seen Jul 22, 2023
    I've been having this problem for a while now and want to make another post asking this now that I've gotten more information.

    Whenever I edit the base stats in "pokemon.txt" to go above 255, the base stats loop through (meaning an input of 256 registers as 1). I have a feeling that this happens in the "Compiler" script. At line: 1600 is where the compiler reads the "pokemon.txt" PBS file. I was wondering if anybody who has more knowledge than I could understand what causes this and a way to allow for base stats to go above 255 without damaging everything else. Any help is appreciated and thanks in advance.
     
  • 1,682
    Posts
    8
    Years
    • Seen yesterday
    Well you are right on the money when it comes to this being caused by the Compiler, but it goes a lot deeper than that. See the compiler just writes the bytes into the proper format, but you'll also have to change every place that reads the bytes for the base stats, and the offsets too.
    Now I'm not going to go into a full step by step of all the changes, but I will bring up the big ones. First the Compiler, quick rundown.
    Code:
        "BaseStats"     => [10,"uuuuuu"],
    So the 10 is the offset and the "uuuuuu"s is the format that it's expecting. Now, def pbCompilePokemonData has its own format for these strings, but "u" is a single byte positive integer. Now for larger than 255, you need a second byte, and you can get it by changing those "u"s to "w", for Positive double byte integers.
    DON'T DO THAT RIGHT AWAY. See the problem here is the next field, Rareness, is at offset 16, and we will run into it if we just blindly change it directly. Now you have two options, shuffle everything down (very bad idea, because you will need to change every single place the game checks for data) or move the base stats somewhere else. Bytes 59 though 75 are free, so that's a good place to put it. So change the 10 to 59, or whatever, so long as you have 12 bytes of room.
    Repeat these changes for def pbCompilePokemonForms.

    Now part two, the base stats. There are at least 3 different places that need to change, maybe more. Finding any of the others is on you, I'm only gonna talk about the main part of the change.
    So this method is from class PokeBattle_Pokemon, but the idea is more or less the same regardless of where you find it.
    Code:
      def baseStats
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,10)
        ret=[
           dexdata.fgetb, # HP
           dexdata.fgetb, # Attack
           dexdata.fgetb, # Defense
           dexdata.fgetb, # Speed
           dexdata.fgetb, # Special Attack
           dexdata.fgetb  # Special Defense
        ]
        dexdata.close
        return ret
      end

    So, first things first, pbDexDataOffset(dexdata,self.fSpecies,10). Don't worry about the first variable, the second is just the species, but the third is what's really important. Remember that 10 in compiler? Well, here it is again. Change that to whatever your new offset is. 59, whatever, I don't care.
    Now the other bit is the fgetb. This grabs a single byte. We don't want that. So change it to fgetw, which grabs two bytes. (You'll see it in def baseExp and if you check the compiler BaseEXP is a "w")

    (Two other sections like this that I found include PBattle_OrgBattleRules and PMinigame_TripleTriad)

    I'm not too sure of any other changes that would need to be done. Possibly formulas expecting the base stats to be capped at 255. I won't get into that, as that's beyond the scope at this point.
     
  • 4
    Posts
    5
    Years
    • Seen Jul 22, 2023
    Thank you so much for the help.
    It works perfectly and looking through the scripts I found no more references to the offset of 10 in the code anywhere else.
     
    Back
    Top