• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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] Fatal error: undefined local variable or method `target' for #<PokeBattle_Battler> - When any attack is used the error pops up

  • 428
    Posts
    5
    Years
    Code:
    [Pokémon Essentials version 19.1]
    [Generation 8 Project v1.1.0]
    [v19.1 Hotfixes 1.0.7]
    
    Exception: NameError
    Message: undefined local variable or method `target' for #<PokeBattle_Battler>
    
    Backtrace:
    155:Battler_UseMove:721:in `block in pbProcessMoveHit'
    155:Battler_UseMove:720:in `each'
    155:Battler_UseMove:720:in `pbProcessMoveHit'
    155:Battler_UseMove:433:in `block in pbUseMove'
    155:Battler_UseMove:431:in `each'
    155:Battler_UseMove:431:in `pbUseMove'
    155:Battler_UseMove:60:in `block in pbProcessTurn'
    012:PBDebug:6:in `logonerr'
    155:Battler_UseMove:59:in `pbProcessTurn'
    181:Battle_Phase_Attack:127:in `block (2 levels) in pbAttackPhaseMoves'

    When any attack is used the error pops up. Then the attack is performed again if the mon isn't fainted. If it is fainted, the error pops up again and again until the game is turned off.
     
    Pretty much exactly what the error says. You're using "target" somewhere around line 721 of Battler_UseMove, but "target" hasn't been defined properly for what you're using it for. If you have any custom code modifications in this section, take a more careful look at it.
     
    I've figured out what code was causing the problem and I've fixed it.

    # Make the target flinch (because of SUPER EFFECTIVE MOVE)
    targets.each do |b|
    if Effectiveness.super_effective?(b.damageState.typeMod)
    b.pbFlinch(user)
    end
    end

    Anyone can use this code if they want. It makes flinches happen if a pokemon is hit with a super effective move, like how in Persona 5 hitting foes with a super-effective move will knock them down and make them miss a turn.
     
    Back
    Top