- 1
- Posts
- 6
- Years
- Seen Jun 28, 2020
I'm working on my first project and it's main feature is a badge dependent level cap (you stop gaining experience once you hit the cap.) I've added to Base Essentials code to achieve this effect in PBExperience Script.
def PBExperience.pbAddExperience(currexp,expgain,growth)
if growth>=6 || growth<0
return ArgumentError.new("The growth rate is invalid.")
end
exp = currexp+expgain
maxexp = pbGetExpInternal(MAXLEVEL,growth)
# Setting the maximum level depending on badges
if $Trainer.numbadges == 0
maxexp = pbGetExpInternal(20,growth)
end
if $Trainer.numbadges == 1
maxexp = pbGetExpInternal(32,growth)
end
if $Trainer.numbadges == 2
maxexp = pbGetExpInternal(45,growth)
end
if $Trainer.numbadges == 3
maxexp = pbGetExpInternal(55,growth)
end
exp = maxexp if exp>maxexp
return exp
end
However, I've also added the Exp All into my game and am using the code that comes with Essentials to handle that. Because of that, I'm getting a glitch where after a pokemon faints and goes through the fainting animation, it stays alive with 1hp and can act the next turn, even though it's sprite moved from fainting. This glitch is extremely inconsistent, it only happens ~10% of the time, isn't pokemon or move specific, but it does only happen when the pokemon that fainted is at the level cap. There's a certain sequence of events in my current save file I'm using to reproduce and test this, and if I remove the level cap code, the glitch doesn't happen, so I'm fairly certain this is what's causing it (turning off the EXP All also prevents the glitch from happening.) This glitch has does not crash the game or give an error message, and the battle continues normally as if the fainted pokemon lived at 1hp, (if the pokemon faints a second time, it stays fainted.) Does anyone have any idea what specifically in my code could be causing this?
def PBExperience.pbAddExperience(currexp,expgain,growth)
if growth>=6 || growth<0
return ArgumentError.new("The growth rate is invalid.")
end
exp = currexp+expgain
maxexp = pbGetExpInternal(MAXLEVEL,growth)
# Setting the maximum level depending on badges
if $Trainer.numbadges == 0
maxexp = pbGetExpInternal(20,growth)
end
if $Trainer.numbadges == 1
maxexp = pbGetExpInternal(32,growth)
end
if $Trainer.numbadges == 2
maxexp = pbGetExpInternal(45,growth)
end
if $Trainer.numbadges == 3
maxexp = pbGetExpInternal(55,growth)
end
exp = maxexp if exp>maxexp
return exp
end
However, I've also added the Exp All into my game and am using the code that comes with Essentials to handle that. Because of that, I'm getting a glitch where after a pokemon faints and goes through the fainting animation, it stays alive with 1hp and can act the next turn, even though it's sprite moved from fainting. This glitch is extremely inconsistent, it only happens ~10% of the time, isn't pokemon or move specific, but it does only happen when the pokemon that fainted is at the level cap. There's a certain sequence of events in my current save file I'm using to reproduce and test this, and if I remove the level cap code, the glitch doesn't happen, so I'm fairly certain this is what's causing it (turning off the EXP All also prevents the glitch from happening.) This glitch has does not crash the game or give an error message, and the battle continues normally as if the fainted pokemon lived at 1hp, (if the pokemon faints a second time, it stays fainted.) Does anyone have any idea what specifically in my code could be causing this?