Advertiser Content

Scripting Question Hard Level Cap

Started by ValiantTrainer94 July 5th, 2019 9:11 PM
  • 1796 views
  • 7 replies
Seen 3 Weeks Ago
Posted 4 Weeks Ago
23 posts
85 Days
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
Seen 3 Weeks Ago
Posted 4 Weeks Ago
23 posts
85 Days
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

Discord: Wolf#1235

Male
Brazil
Seen 8 Hours Ago
Posted 8 Hours Ago
738 posts
1.1 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):
  if exp > 0
    if thispoke.level>badgelevel
      pbDisplayPaused(_INTL("{1} gained a measly {2} Exp. Points.",thispoke.name,exp))
    elsif isOutsider
    end
  end
About your code above you forgot to put an 'end' to finish what 'if exp>0' does:
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
end
Try to read what you wrote because you forgot something.
Seen 3 Weeks Ago
Posted 4 Weeks Ago
23 posts
85 Days
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):
  if exp > 0
    if thispoke.level>badgelevel
      pbDisplayPaused(_INTL("{1} gained a measly {2} Exp. Points.",thispoke.name,exp))
    elsif isOutsider
    end
  end
About your code above you forgot to put an 'end' to finish what 'if exp>0' does:
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
end
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!
Seen 3 Weeks Ago
Posted 4 Weeks Ago
23 posts
85 Days
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:

---------------------------
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
Advertiser Content