• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

Returning the base stats of a mon?

  • 7
    Posts
    9
    Years
    • Seen Nov 19, 2020
    Hi, I'm using someone elses script which randomly generates pokemon in each instance you are going to battle one. I'm attempting to set it up in a way where the pokemon are in separate tiers based on base stats.

    species = rand(PBSpecies.maxValue - 1) + 1
    bs = PBSpecies::species.baseStats <-- this line is incorrect, but I have no idea what syntax or methods I should use
    for i in 0..5
    baseStatTotal += bs
    end

    I'm attempting to store the base stats of the randomly generated "species" into "bs" and then add them up in the loop but I'm crashing on use. What exactly should I write in for " bs = PBSpecies::species.baseStats" to get the base stats into "bs"
     
    Code:
      def getBaseStatTotal(species)
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,species,10)
        bs=[
           dexdata.fgetb, # HP
           dexdata.fgetb, # Attack
           dexdata.fgetb, # Defense
           dexdata.fgetb, # Speed
           dexdata.fgetb, # Special Attack
           dexdata.fgetb  # Special Defense
        ]
        dexdata.close
        bst=0
        for i in bs
          bst+=i
        end
        return bst
      end
     
    Thank you very much, works like a charm

    Though I am confused as to why the "i" in the chunk of code below automatically knows to give you bs

    for i in bs
    bst+=i
    end
     
    Thank you very much, works like a charm

    Though I am confused as to why the "i" in the chunk of code below automatically knows to give you bs

    for i in bs
    bst+=i
    end


    Because the variable i isn't actually the index of the entry in the table, but the actual entry. If you want i to be the index, you'd have to use something like

    for i in 0...bs.length
     
    Back
    Top