Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Reload this Page [Question] Returning the base stats of a mon?

Notices
For all updates, view the main page.

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.



Reply
 
Thread Tools
  #1    
Old 3 Weeks Ago (12:29 PM).
Krigeris Krigeris is offline
 
Join Date: Aug 2015
Posts: 3
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[i]
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"
Reply With Quote
  #2    
Old 3 Weeks Ago (06:22 PM).
Rot8er_Cone/'s Avatar
Rot8er_Cone/ Rot8er_Cone/ is offline
 
Join Date: May 2015
Location: The Dissa Region
Gender: Male
Posts: 186
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
__________________
If you credit me, call me Rot8er_ConeX; my phone glitched when I was signing up and I didn't notice until the process was complete.

Features of Pokemon Entropy
Reply With Quote
  #3    
Old 3 Weeks Ago (12:18 PM).
Krigeris Krigeris is offline
 
Join Date: Aug 2015
Posts: 3
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[i]

for i in bs
bst+=i
end
Reply With Quote
  #4    
Old 3 Weeks Ago (12:41 PM).
Rot8er_Cone/'s Avatar
Rot8er_Cone/ Rot8er_Cone/ is offline
 
Join Date: May 2015
Location: The Dissa Region
Gender: Male
Posts: 186
Quote originally posted by Krigeris:
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[i]

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
Reply With Quote
  #5    
Old 3 Weeks Ago (12:48 PM).
Krigeris Krigeris is offline
 
Join Date: Aug 2015
Posts: 3
awesome thanks again
Reply With Quote
Reply
Quick Reply

Sponsored Links

You may also like.. (Beta)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 11:11 AM.