• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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