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

Pokemon Essentials v21 help with an error

  • 2
    Posts
    3
    Years
    • Seen Jan 18, 2025
    Hello,
    I am making an ability that swaps out the user after damaging the opponent with a move, however, an error occurs when I try to send in the Pokemon.
    Although you can ignore this issue and it works afterward, it does not feel fluid in the slightest, but i can't seem to understand the problem. would love some help!
    The actual code for the Ability:
    Code:
    Battle::AbilityEffects::OnDealingHit.add(:COWARDLYSPIRIT,
      proc { |ability, user, move, target, battle, battler, move_user, targets|
     def pbDamagingMove?
        return false if @presentDmg == 0
      end
    
        if !move.pbDamagingMove?
        battle.pbShowAbilitySplash(user)
             battle.pbDisplay(_INTL("{1} returned!", user.pbThis(true)))
         battle.pbHideAbilitySplash(user)
        return if user.fainted?
        newPkmn = battle.pbGetReplacementPokemonIndex(user.index)
        return if newPkmn < 0
        battle.pbRecallAndReplace(user.index, user, newPkmn)
        battle.pbClearChoice(user.index)   # Replacement Pokémon does nothing this round
        battle.moldBreaker = false
        battle.pbOnBattlerEnteringBattle(user)
    
      end
      }
    )
    the Error message itself:
    Exception `TypeError' at Section151:278 - no implicit conversion of Battle::Battler into Integer
     
    This is an easy fix. This:
    Code:
    battle.pbRecallAndReplace(user.index, user, newPkmn)

    Should be this:
    Code:
    battle.pbRecallAndReplace(user.index, newPkmn)

    You won't get the error message any more.

    You actually will have a bigger problem with the code that I currently can't get to right now. If this is your last/only Pokemon, it will attempt to switch and you will be stuck in the menu because you can't switch into the Pokemon currently in battle. You need to put in some sort of "if last pokemon, ability does not activate" failsafe in the code.
     
    Thank you for the fix, I will try to fix the problem you mentioned, thank you for noting that!
     
    Back
    Top