• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • 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.

[Scripting Question] Level Caps for Essentials 17.2

  • 8
    Posts
    4
    Years
    • Seen Nov 23, 2021
    Hey I am new to scripting and I am wondering how to put a level cap before every gym battle in my game. I know that this question has been asked before but the previous posts about it are old and I don't really understand them. I know that 18 version is out but i don't want to restart my project. If you know how to script this for 17.2 i would greatly appreciate your help.
     
    In PBExperience find:
    Code:
      def self.maxLevel
        return MAXIMUM_LEVEL
      end

    and make it:

    Code:
      def self.maxLevel
        return $game_variables[X]
      end

    Replace X with the variable that you want to use.

    I am in a similar scenario to the person above and "def self.maxLevel" only exists in v18 cause I can't find it in v17.2
    is there another way to get this effect but in version 17.2
     
    I am in a similar scenario to the person above and "def self.maxLevel" only exists in v18 cause I can't find it in v17.2
    is there another way to get this effect but in version 17.2

    My bad, I saw the setting for MAXIMUMLEVEL in both v17.2 and v18 and thought they were the same, here is what you have to do in v17.2:

    In PBExperience change the following methods to use $game_variables instead of MAXLEVEL:
    Code:
    def PBExperience.pbGetMaxExperience(growth)
        if growth>=6 || growth<0
          return ArgumentError.new("The growth rate is invalid.")
        end
        return pbGetExpInternal($game_variables[X],growth)
      end
    
      def PBExperience.pbGetStartExperience(level,growth)
        if growth>=6 || growth<0
          return ArgumentError.new("The growth rate is invalid.")
        end
        if level<0
          return ArgumentError.new("The level is invalid.")
        end
        level = $game_variables[X] if level>$game_variables[X]
        return pbGetExpInternal(level,growth)
      end
    
      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($game_variables[X],growth)
        exp = maxexp if exp>maxexp
        return exp
      end
    
      def PBExperience.pbGetLevelFromExperience(exp,growth)
        if growth>=6 || growth<0
          return ArgumentError.new("The growth rate is invalid.")
        end
        maxexp = pbGetExpInternal($game_variables[X],growth)
        exp = maxexp if exp>maxexp
        i = 0
        for j in 0..$game_variables[X]
          currentExp = pbGetExpInternal(i,growth)
          return i if exp==currentExp
          return i-1 if exp<currentExp
          i += 1
        end
        return $game_variables[X]
      end


    In PItem_ItemEffects do the same for rarecandy:
    Code:
    ItemHandlers::UseOnPokemon.add(:RARECANDY,proc{|item,pokemon,scene|
       if pokemon.level>=$game_variables[X] || (pokemon.isShadow? rescue false)
         scene.pbDisplay(_INTL("It won't have any effect."))
         next false
       else
         pbChangeLevel(pokemon,pokemon.level+1,scene)
         scene.pbHardRefresh
         next true
       end
    })
     
    Back
    Top