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

[Error] Newbie in need of help, Ability Script error

  • 10
    Posts
    3
    Years
    • Seen Jun 13, 2022
    I don't do scripting, most of this is copy-pasted and things I inferred from similar scripts. I wanted to make an ability that made you immune to all types of attacks (a 'god' ability) and I tried to use levitate as a base. The thing with Levitate though, is that It works on a different logic than regular ability scripts. So i tried to make a custom "airborne" log and came up with this for Battler_usemoves_Success:
    Code:
    if move.damagingMove? && move.calcType == :ELECTRIC or WATER or NORMAL or FIRE or GRASS or ICE or FIGHTING or POISON or GROUND or FLYING or PSYCHIC or BUG or ROCK or GHOST or DARK or DRAGON or STEEL or FAIRY &&
           target.godveil?
            if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
              @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
            else
              @battle.pbDisplay(_INTL("{1} avoided the attack with {2}!",target.pbThis,target.abilityName))
            end
            @battle.pbHideAbilitySplash(target)
            return false
          end
    (and i also added this to Pokebattle_Battler beforehand of course)
    Code:
    def godveil?
        return true if hasActiveAbility?(:GODVEIL)
        return false
      end
    But when I ran the script, it worked fine but it kept on giving me an error message over the name "Water"?
    Exception: NameError
    Message: uninitialized constant PokeBattle_Battler::WATER

    Backtrace:
    157:Battler_UseMove_SuccessChecks:443:in `pbSuccessCheckAgainstTarget'
    155:Battler_UseMove:395:in `block in pbUseMove'
    155:Battler_UseMove:392:in `each'
    155:Battler_UseMove:392:in `pbUseMove'
    155:Battler_UseMove:60:in `block in pbProcessTurn'
    012:PBDebug:6:in `logonerr'
    155:Battler_UseMove:59:in `pbProcessTurn'
    180:Battle_Phase_Attack:126:in `block (2 levels) in pbAttackPhaseMoves'
    180:Battle_Phase_Attack:122:in `each'
    180:Battle_Phase_Attack:122:in `block in pbAttackPhaseMoves'

    I don't know what I'm doing wrong. I don't know enough about coding to figure out the problem and I'm really tired rn to try and find it. And I don't want it to be affected by Moldbreaker. Also, would it be better if it were like Lightning Rod and most of the other abilities in the script? If so, how would I get it so it does not get any stat boosts and it only makes the pokemon is immune?
     
    I don't do scripting, most of this is copy-pasted and things I inferred from similar scripts. I wanted to make an ability that made you immune to all types of attacks (a 'god' ability) and I tried to use levitate as a base. The thing with Levitate though, is that It works on a different logic than regular ability scripts. So i tried to make a custom "airborne" log and came up with this for Battler_usemoves_Success:
    Code:
    if move.damagingMove? && move.calcType == :ELECTRIC or WATER or NORMAL or FIRE or GRASS or ICE or FIGHTING or POISON or GROUND or FLYING or PSYCHIC or BUG or ROCK or GHOST or DARK or DRAGON or STEEL or FAIRY &&
           target.godveil?
            if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
              @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
            else
              @battle.pbDisplay(_INTL("{1} avoided the attack with {2}!",target.pbThis,target.abilityName))
            end
            @battle.pbHideAbilitySplash(target)
            return false
          end
    (and i also added this to Pokebattle_Battler beforehand of course)
    Code:
    def godveil?
        return true if hasActiveAbility?(:GODVEIL)
        return false
      end
    But when I ran the script, it worked fine but it kept on giving me an error message over the name "Water"?
    Exception: NameError
    Message: uninitialized constant PokeBattle_Battler::WATER

    Backtrace:
    157:Battler_UseMove_SuccessChecks:443:in `pbSuccessCheckAgainstTarget'
    155:Battler_UseMove:395:in `block in pbUseMove'
    155:Battler_UseMove:392:in `each'
    155:Battler_UseMove:392:in `pbUseMove'
    155:Battler_UseMove:60:in `block in pbProcessTurn'
    012:PBDebug:6:in `logonerr'
    155:Battler_UseMove:59:in `pbProcessTurn'
    180:Battle_Phase_Attack:126:in `block (2 levels) in pbAttackPhaseMoves'
    180:Battle_Phase_Attack:122:in `each'
    180:Battle_Phase_Attack:122:in `block in pbAttackPhaseMoves'

    I don't know what I'm doing wrong. I don't know enough about coding to figure out the problem and I'm really tired rn to try and find it. And I don't want it to be affected by Moldbreaker. Also, would it be better if it were like Lightning Rod and most of the other abilities in the script? If so, how would I get it so it does not get any stat boosts and it only makes the pokemon is immune?

    Your syntax is all out of wack and doesn't make any sense when read out. The way the first line reads if you translated it into English would say:
    "If this move is a damaging move, AND it's an Electric-type move, OR Water symbol, OR Normal symbol, OR Fire symbol...etc"

    You see, just slapping the symbol for something in a sentence doesn't make any sense. All a symbol is is a representation of something in the game data. It's just a general concept of "Water type", but that doesn't actually mean anything unless you give it context. You're writing it out as if you're speaking it out in English. Like "If the move is Electric-type, or Water type, or Normal-type, etc..", but that's not how the code reads it. Unless you specifically say "move.calcType == " for EACH type, the code has no idea what you're talking about. It doesn't "remember" that you're talking specifically about the type of a move unless you reference that that's what it's looking for with every single instance.

    So if you did "move.calcType == :ELECTRIC || move.calcType == :WATER || move.calcType ==:NORMAL" etc. for all the types, it would probably work (assuming the rest of the code is functional). However, that's obviously a highly unoptimized way of writing it out, and leaves you prone to many potential errors. There's far easier ways to just check for all potential types at once.

    However, let's ignore that even, because just the base you're starting with is pretty unoptimized. For instance, why use Levitate as a base - which provides immunity to only one type - when you could instead use something like Wonder Guard that already basically makes Shedinja invincible outside of Super Effective moves? Wouldn't that be a simpler base to work off of. All you'd probably need to do is delete the one line that checks for Super Effective moves, and tada! You made your Pokemon immune to all types.
     
    Omg I completely forgot about wonderguard, I tried it and it worked tysm! Also thank you for telling me what I was doing wrong with the scripts, again sorry, I'm kinda new so explaining what Is really going to help in the future, thx ;)
     
    Back
    Top