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

One Pokemon not gaining EXP

  • 8
    Posts
    11
    Years
    • Seen Sep 30, 2012
    While testing my modified** game, I caught a Snorlax. Now, whenever that Snorlax participates in a battle, it does not gain EXP, nor do any Pokemon in later positions in the party who participated gain EXP. Here are the Snorlax's attributes:

    Name: Selene
    ID: 28657
    Lv 20
    EXP:10000
    Male
    HP:98
    Atk:53
    Def:40
    Sp.Atk:36
    Sp.Def:55
    Speed:16
    Ability:Immunity
    Attacks
    Amnesia
    Lick
    Belly Drum
    Yawn
    Item:Leftovers
    Impish nature
    Mischievous

    If I put the Snorlax in the front of my party and begin a wild encounter, no Pokemon gain EXP at the end. If I put any of my other Pokemon in front and only use them, they gain EXP. If I put another Pokemon in front and switch to Snorlax after the battle starts, the starting Pokemon gains EXP, but Snorlax does not. The battle screen simply fades out right after the text "wild [species] fainted." It seems like the EXPGain script is ending prematurely when it gets to Snorlax.

    I took the Leftovers away from Snorlax and tested again: all results are the same.

    **Changes I have made to the scripts are as follows. All of these changes are made so that Pokemon will gain half of their EXP when a battle ends, but will not gain the other half until they are healed.

    In PokemonBattle_Pokemon script section
    After line:
    attr_accessor :cool,:beauty,:cute,:smart,:tough,:sheen # Contest stats
    added line:
    attr_accessor(:storedEXP) # EXP stacked up but not gained until healing
    In def initialize, added:
    @storedEXP=@exp

    In PokemonBattle_Battle script section

    In def pbGainEXP​
    Changed:
    Code:
    exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
                    isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG)
    growthrate=thispoke.growthrate
    newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
    exp=newexp-thispoke.exp

    To:
    Code:
    exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
                    isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG)
    immediateEXP=(exp/2)
    growthrate=thispoke.growthrate
    newexp=PBExperience.pbAddExperience(thispoke.exp,immediateEXP,growthrate)
    newStoredEXP=PBExperience.pbAddExperience(thispoke.storedEXP,exp,growthrate)
    thispoke.storedEXP=newStoredEXP
    exp=newexp-thispoke.exp

    I added a function to PBExperience called PBExperience.pbRestPokemon(pokemon) which sets a Pokemon's exp to its storedEXP, updates its level, and teaches it the new level's moves. I won't include that unless requested because it is never being called in these testing scenarios. It is only called when the party is healed.

    The only similar thing I found in known bugs was a vague complaint months ago about Pokemon not gaining Experience, which was apparently fixed.

    Okay, I just changed:
    newStoredEXP=PBExperience.pbAddExperience(thispoke.storedEXP,exp,growthrate)
    thispoke.storedEXP=newStoredEXP

    To:
    if thispoke.storedEXP
    newStoredEXP=PBExperience.pbAddExperience(thispoke.storedEXP,exp,growthrate)
    thispoke.storedEXP=newStoredEXP
    else
    newStoredEXP=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
    thispoke.storedEXP=newStoredEXP
    end

    And it worked. I must have not been initializing the storedEXP value for encountered Pokemon correctly. I thought I was when I wrote @storedEXP = @exp in PokemonBattle_Pokemon as stated before. Knowing that, can anyone tell me where I should be initializing that value?
     
    Last edited:

    Maruno

    Lead Dev of Pokémon Essentials
  • 5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    Did you add the line @storedEXP=@exp after the line self.level=level? If you added it before then, there's no experience value at that point so @storedEXP is set to nil, which causes a problem in your other scripts when it's supposed to be a number.
     
  • 8
    Posts
    11
    Years
    • Seen Sep 30, 2012
    That would be the problem. I added it into initialize instead of calcStats. It works now; thank you.
     
    Back
    Top