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

[Scripting Question] Hard Level Cap

34
Posts
4
Years
    • Seen Apr 27, 2024
    Hey there, I found this script on this website and think I've followed the instructions to the letter, but continue getting a syntax error whilst trying to implement the hard level cap.

    The original thread is on the site, titled "How to remove Pokémon not obeying orders?"
    And the script is:
    badgelevel=MAXIMUMLEVEL
    if pbOwnedByPlayer?(thispoke.partyIndex) && internalbattle
    badgelevel=10
    badgelevel=20 if pbPlayer.numbadges>=1
    badgelevel=30 if pbPlayer.numbadges>=2
    badgelevel=40 if pbPlayer.numbadges>=3
    badgelevel=50 if pbPlayer.numbadges>=4
    badgelevel=60 if pbPlayer.numbadges>=5
    badgelevel=70 if pbPlayer.numbadges>=6
    badgelevel=80 if pbPlayer.numbadges>=7
    badgelevel=100 if pbPlayer.numbadges>=8
    end
    if thispoke.level>badgelevel
    newexp=PBExperience.pbAddExperience(thispoke.exp,1,growthrate)
    else
    newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
    end
    exp=newexp-thispoke.exp
    if exp > 0
    if thispoke.level>badgelevel
    pbDisplayPaused(_INTL("{1} gained a measly {2} Exp. Points.",thispoke.name,exp))
    elsif isOutsider

    Could anyone by any chance help me by providing a modified version of the Pokebattle_Battle script, or assist in specifying exactly where this goes? This script is 3.9 years old so it may just be outdated and if that is the case, does anyone know of a v17 alternative?

    All the best and many thanks,
    Valiant
     
    87
    Posts
    7
    Years
    • Seen Nov 22, 2023
    What exactly are you trying to do?
    Are you trying to make it so that a Pokemon will obey, despite their level?
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    It looks like the idea is to prevent the Pokémon gaining experience if it's at or above the badge level.

    Anyway, I don't see what part of the posted code causes a syntax error, so I guess it's coming from where you've added it? I assume that "elsif isOutsider" and below is all part of Essentials v17?
     
    34
    Posts
    4
    Years
    • Seen Apr 27, 2024
    Hey yeah, I'm trying to limit experience to 0 if the player doesn't have the correct badge, to prevent over-levelling. It goes somewhere in this section of the PokeBattle_Battle script:

    growthrate=thispoke.growthrate
    newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
    exp=newexp-thispoke.exp
    if exp>0
    if showmessages
    if isOutsider
    pbDisplayPaused(_INTL("{1} gained a boosted {2} Exp. Points!",thispoke.name,exp))
    else
    pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
    end
    end
    newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
    tempexp=0
    curlevel=thispoke.level
    if newlevel<curlevel
    debuginfo="#{thispoke.name}: #{thispoke.level}/#{newlevel} | #{thispoke.exp}/#{newexp} | gain: #{exp}"
    raise RuntimeError.new(_INTL("The new level ({1}) is less than the Pokémon's\r\ncurrent level ({2}), which shouldn't happen.\r\n[Debug: {3}]",
    newlevel,curlevel,debuginfo))
    return
    end

    But I wasn't sure exactly how to modify it. The error I got each time was "Syntax Error" with no further details.
    Thanks for the prompt responses peeps!
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Syntax Error is when you forgot to add or remove some 'if', 'else', 'end', ')', etc.
    I checked you script into main post you forgot to put 'end', 'end', like (the last lines):
    Code:
      if exp > 0
        if thispoke.level>badgelevel
          pbDisplayPaused(_INTL("{1} gained a measly {2} Exp. Points.",thispoke.name,exp))
        elsif isOutsider
    [B]    end
      end[/B]

    About your code above you forgot to put an 'end' to finish what 'if exp>0' does:
    Code:
    growthrate=thispoke.growthrate
    newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
    exp=newexp-thispoke.exp
    if exp>0
      if showmessages
        if isOutsider
          pbDisplayPaused(_INTL("{1} gained a boosted {2} Exp. Points!",thispoke.name,exp))
        else
          pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
        end
      end
      newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
      tempexp=0
      curlevel=thispoke.level
      if newlevel<curlevel
        debuginfo="#{thispoke.name}: #{thispoke.level}/#{newlevel} | #{thispoke.exp}/#{newexp} | gain: #{exp}"
        raise RuntimeError.new(_INTL("The new level ({1}) is less than the Pokémon's\r\ncurrent level ({2}), which shouldn't happen.\r\n[Debug: {3}]",
        newlevel,curlevel,debuginfo))
        return
      end
    [B]end[/B]
    Try to read what you wrote because you forgot something.
     
    34
    Posts
    4
    Years
    • Seen Apr 27, 2024
    Syntax Error is when you forgot to add or remove some 'if', 'else', 'end', ')', etc.
    I checked you script into main post you forgot to put 'end', 'end', like (the last lines):
    Code:
      if exp > 0
        if thispoke.level>badgelevel
          pbDisplayPaused(_INTL("{1} gained a measly {2} Exp. Points.",thispoke.name,exp))
        elsif isOutsider
    [B]    end
      end[/B]

    About your code above you forgot to put an 'end' to finish what 'if exp>0' does:
    Code:
    growthrate=thispoke.growthrate
    newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
    exp=newexp-thispoke.exp
    if exp>0
      if showmessages
        if isOutsider
          pbDisplayPaused(_INTL("{1} gained a boosted {2} Exp. Points!",thispoke.name,exp))
        else
          pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
        end
      end
      newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
      tempexp=0
      curlevel=thispoke.level
      if newlevel<curlevel
        debuginfo="#{thispoke.name}: #{thispoke.level}/#{newlevel} | #{thispoke.exp}/#{newexp} | gain: #{exp}"
        raise RuntimeError.new(_INTL("The new level ({1}) is less than the Pokémon's\r\ncurrent level ({2}), which shouldn't happen.\r\n[Debug: {3}]",
        newlevel,curlevel,debuginfo))
        return
      end
    [B]end[/B]
    Try to read what you wrote because you forgot something.

    I'll try that out; but thanks much bud! I have zero scripting knowledge so I'm tryna piece this together from what I can see. Appreciate the support, everyone!
     
    34
    Posts
    4
    Years
    • Seen Apr 27, 2024
    Code:
    growthrate=thispoke.growthrate
        badgelevel=MAXIMUMLEVEL
                  if pbOwnedByPlayer?(thispoke.partyIndex) && internalbattle
                    badgelevel=10
                    badgelevel=20  if pbPlayer.numbadges>=1
                    badgelevel=30  if pbPlayer.numbadges>=2
                    badgelevel=40  if pbPlayer.numbadges>=3
                    badgelevel=50  if pbPlayer.numbadges>=4
                    badgelevel=60  if pbPlayer.numbadges>=5
                    badgelevel=70  if pbPlayer.numbadges>=6
                    badgelevel=80  if pbPlayer.numbadges>=7
                    badgelevel=100 if pbPlayer.numbadges>=8
                  end
                  if thispoke.level>badgelevel
                    newexp=PBExperience.pbAddExperience(thispoke.exp,1,growthrate)
                  else
                    newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
                  end
                  exp=newexp-thispoke.exp
                  if exp > 0
                    if thispoke.level>badgelevel
                      pbDisplayPaused(_INTL("{1} gained a measly {2} Exp. Points.",thispoke.name,exp))
                    elsif isOutsider
                      end 
                    end 
       if exp>0
          if showmessages
            if thispoke.level>badgelevel
              pbDisplayPaused(_INTL("{1} gained a measly {2} Exp. Points.",thispoke.name,exp))
            elsif isOutsider
              pbDisplayPaused(_INTL("{1} gained a boosted {2} Exp. Points!",thispoke.name,exp))
            else
              pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
            end
          end
          newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
          tempexp=0
          curlevel=thispoke.level
          if newlevel<curlevel
            debuginfo="#{thispoke.name}: #{thispoke.level}/#{newlevel} | #{thispoke.exp}/#{newexp} | gain: #{exp}"
            raise RuntimeError.new(_INTL("The new level ({1}) is less than the Pokémon's\r\ncurrent level ({2}), which shouldn't happen.\r\n[Debug: {3}]",
                                   newlevel,curlevel,debuginfo))
            return
          end
          if thispoke.respond_to?("isShadow?") && thispoke.isShadow?
            thispoke.exp+=exp
          else
            tempexp1=thispoke.exp
            tempexp2=0


    So I've taken the advice on board and tried to fix the script. Whereas it doesn't pop up with the same error, I now get this one:

    Code:
    ---------------------------
    Pokemon Essentials
    ---------------------------
    [Pokémon Essentials version 17.2]
    
    Exception: NoMethodError
    
    Message: undefined method `partyIndex' for #<PokeBattle_Pokemon:0xc8a5440>
    
    PokeBattle_Battle:1938:in `pbGainExpOne'
    
    PokeBattle_Battle:1813:in `pbGainEXP'
    
    PokeBattle_Battle:1807:in `each'
    
    PokeBattle_Battle:1807:in `pbGainEXP'
    
    PokeBattle_Battle:1778:in `each'
    
    PokeBattle_Battle:1778:in `pbGainEXP'
    
    PokeBattle_Battler:3294:in `pbUseMove'
    
    PokeBattle_Battler:3402:in `pbProcessTurn'
    
    PokeBattle_Battler:3401:in `logonerr'
    
    PokeBattle_Battler:3401:in `pbProcessTurn'

    And I have no idea where to start with fixing it. Hopefully one of you fine fellows can nudge me along again :D
     
    Back
    Top