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

One Pokemon not gaining EXP

  • 6
    Posts
    12
    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:
    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.
     
    That would be the problem. I added it into initialize instead of calcStats. It works now; thank you.
     
    Back
    Top