• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Thunder Wave not working

  • 4
    Posts
    8
    Years
    • Seen Feb 6, 2017
    Hi all!

    Tweaking the AI scripts a little bit, I've run into a problem. I wanted to make the opposing pokemon to always use Thunder Wave in case your pokemon (the one controled by the player) was faster. Looking through the scripts I ended up bumping into this:

    Code:
    when 0x1F
    aspeed=pbRoughStat(attacker,PBStats::SPEED,skill)
    ospeed=pbRoughStat(opponent,PBStats::SPEED,skill)
    if aspeed<ospeed && aspeed*2>ospeed
        score+=30
    end

    In this example, a reference to both pokemon speed is made to decide wether to use Flame Charge or not.
    So adapting this I made a custom one for Thunder Wave:

    Code:
    aspeed=pbRoughStat(attacker,PBStats::SPEED,skill)
    ospeed=pbRoughStat(opponent,PBStats::SPEED,skill)
    if (move.basedamage==0) && (ospeed>aspeed) &&
       (opponent.pbCanParalyze?(attacker,false)) &&
       (isConst?(move.type,PBTypes,:ELECTRIC))
       score+=120000
    end

    Which caused the following error:

    Spoiler:


    I'd like some help to spot what I'm doing wrong.

    Thanks in advance!
     
    Did you put it before or after the above?
    Did you make sure to put enough ends in?

    The error it's throwing out is that pbRoughStat doesn't exist (which it clearly does), which means something's not closed properly in most cases.
     
    I put it inside the case "when 0x07, 0x08, 0x09, 0xC5" (0x07 is Thunder Wave) in PokeBattle_AI.

    I tested that fragment of the code just to check what you said about the ends and it still causes the same error.

    Code:
    when 0x07, 0x08, 0x09, 0xC5 
    
    aspeed=pbRoughStat(attacker,PBStats::SPEED,skill)
    ospeed=pbRoughStat(opponent,PBStats::SPEED,skill)
          if ((move.basedamage==0) && (ospeed>aspeed) &&
             (opponent.pbCanParalyze?(attacker,false)) &&
             (isConst?(move.type,PBTypes,:ELECTRIC)))
                score+=120000
          end

    That's the problem. That pbRoughStat clearly exists and I don't think I've made any dumb mistake.

    BTW, it's only thunder wave what is causing the error. Every single other move seems to work perfectly fine.
     
    Back
    Top