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

[Error] NoMethodError - undefined method 'iv' for #<PokeBattle_Battler>

SupGamer NL

SupGamer NL
  • 6
    Posts
    7
    Years
    I don't know why, but whenever a Pokémon wants to use the move Hidden Power I get this error:

    Exception: NoMethodError
    Message: undefined method 'iv' for #<PokeBattle_Battler>

    I have a screenshot of the full error with the backtrace.
    NoMethodError - undefined method 'iv' for #<PokeBattle_Battler>


    I can also add the errorlog.txt to this thread.
    Spoiler:

    I have tried to find similar cases, but at last, I didn't find anything related to my problem.
    I hope someone can help me with this problem
     
    Last edited:
  • 56
    Posts
    10
    Years
    • Seen Jul 8, 2023
    I have the same exact problem. I have the gen 8 project installed but not EBDX, if that helps

    EDIT: This problem doesn't occur in default essentials 19.1
     
    Last edited:
  • 104
    Posts
    2
    Years
    • Seen Mar 12, 2024
    So, it seems to be a multiple step problem, and it appears to be related to the Gen 8 project (or at least the process of installing it). The first issue is that "iv" is undefined in the PokeBattle_Battler, where it is normally defined in v19.1. Under "class PokeBattle_Battler" add the following line of code:

    Code:
    attr_accessor :iv

    However, if you just do that, it gives you a different error. You also need to go to the "Battler_Initialize" and head to the "def pbInitPokemon(pkmn,idxParty)". Towards the bottom of that definition you'll see this:

    Code:
    pkmn.moves.each_with_index do |m,i|
          if (isSpecies?(:ZACIAN) || isSpecies?(:ZAMAZENTA)) && @form == 1 && m.id == :IRONHEAD
            moveID = isSpecies?(:ZACIAN) ? :BEHEMOTHBLADE : :BEHEMOTHBASH
            @moves[i] = PokeBattle_Move.from_pokemon_move(@battle,Pokemon::Move.new(moveID))
            @moves[i].realMove = m
            maxPP =  GameData::Move.get(moveID).total_pp
            @moves[i].total_pp =  maxPP + (maxPP * m.ppup / 5)
            calcPP = ((m.pp/m.total_pp.to_f) * @moves[i].total_pp).to_i
            pbSetPP(@moves[i],calcPP)
          else
            @moves[i] = PokeBattle_Move.from_pokemon_move(@battle,m)
          end
        end
    end

    In between the first and second "end" at the bottom of the script, you need to add these lines
    Code:
    @iv           = {}
        GameData::Stat.each_main { |s| @iv[s.id] = pkmn.iv[s.id] }

    After doing both these steps, you should no longer get an error when using Hidden Power. I tested it, it works both when you use it and when the opponent uses it. And the type is still dependent on your ivs.
     

    SupGamer NL

    SupGamer NL
  • 6
    Posts
    7
    Years
    Thanks, it works now! Thank you so much, I've also added the code in the newly generated PokeBattle_Battler.rb & PokeBattle_Initialize.rb just to be sure.

    Spoiler:
     
    Back
    Top