• 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 Conquest 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] Error during a battle

AskipLudo

The Masked Guy
  • 159
    Posts
    8
    Years
    Hello, It's been a long time not messing with Pokemon essentials and I don't know who I got an error while doing a battle, I've made like 5 before this one,

    This is the error:

    [2023-09-16 03:07:26 +0200]
    [Pokémon Essentials version 21.1]
    [v21.1 Hotfixes 1.0.1]

    Exception: NoMethodError
    Message: undefined method `has_active_ability?' for #<Battle::Battler>

    Backtrace:
    [Generation 9 Pack] [004] AI_MoveEffects.rb:842:in `block in <main>'
    Event_Handlers:139:in `trigger'
    Battle_AI:98:in `move_will_fail?'
    AI_ChooseMove:190:in `pbPredictMoveFailure'
    AI_ChooseMove:38:in `block in pbGetMoveScores'
    Battle_Battler:461:in `block in eachMoveWithIndex'
    Battle_Battler:461:in `each'
    Battle_Battler:461:in `each_with_index'
    Battle_Battler:461:in `eachMoveWithIndex'
    AI_ChooseMove:25:in `pbGetMoveScores'

    And about what I'm doing i'm just making the player into an AI so that both fight themselves. Found the code somewhere on the forum and added it to my essentials and worked perfectly until a fight against 2 trainers
    One with a Paras and one with a Poliwhirl.

    Thanks for any help (and maybe any way to improve the AI vs AI thing well be nice)

    Edit: After some checking seems like it's pointing to this code:
    #===============================================================================
    # Rest
    #===============================================================================
    # Adds failure check with the Purifying Salt ability.
    Battle::AI::Handlers::MoveFailureCheck.add("HealUserFullyAndFallAsleep",
    proc { |move, user, ai, battle|
    next true if user.battler.has_active_ability?(:PURIFYINGSALT)
    next true if !user.battler.canHeal?
    next true if user.battler.asleep?
    next true if !user.battler.pbCanSleep?(user.battler, false, move.move, true)
    next false
    }
    )
    Because the Poliwhirl actually have the Rest move
     
    Last edited:
    Hello, @Ludow79,
    I believe this error may be due to the new script imported (Gen 9 Pack) being based on a later version of essentials than your other scripts
    If this is the problem, then this can be fixed by putting:
    Code:
    class Battle::Battler
      alias has_active_ability? hasActiveAbility?
    end
    However, you should expect to find other errors further on for the same reason
    Hope this helps!
    Swdfm
     
    Well I didn't tested much those days but the last time I test with a pokemon with rest and the "has_active_ability?" changed to "hasActiveAbility?" in line 842 didn't made any error, I guess everything didnt get changed

    Edit: The dev will fix this next update so it will be fixed :P
     
    Last edited:
    Back
    Top