Hey all, I made a script for Beast Boost that utilizes for loops to check which stat of the Pokémon should be raised. I tried my best to condense it, but this is about as short as I could make it. It works really well in game and I haven't had any issues yet. If you want to use it, just paste it under '# Moxie' in the 'PokeBattle_Battler' script section. If you have any questions don't hesitate to ask!
Code:
# Beast Boost
if user.hasWorkingAbility(:BEASTBOOST) && target.fainted?
# Store user's current stats and boostable stats in seperate arrays
userStats=[user.attack,user.defense,user.spatk,user.spdef,user.speed]
statBoost=[PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPATK,PBStats::SPDEF,PBStats::SPEED]
statCheck=0
statToBoost=0
boost=0
# Check which user stat is the most proficient
for i in userStats
if i>statCheck
statCheck=i
statToBoost=userStats.index(i)
end
for j in statBoost
if statBoost.index(j)==statToBoost
boost=statBoost.index(j)
end
end
end
if !user.pbCanIncreaseStatStage?(boost,user)
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",userFb.pbThis))
end
if user.pbIncreaseStatWithCause(boost,1,user,PBAbilities.getName(user.ability))
PBDebug.log("[Ability triggered] #{user.pbThis}'s Beast Boost")
end
end