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

Pokemon Essentials v21 help with an error

2
Posts
2
Years
    • Seen Oct 12, 2023
    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
     
    104
    Posts
    2
    Years
    • Seen Mar 12, 2024
    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.
     
    2
    Posts
    2
    Years
    • Seen Oct 12, 2023
    Thank you for the fix, I will try to fix the problem you mentioned, thank you for noting that!
     
    Back
    Top