- 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:
the Error message itself:
Exception `TypeError' at Section151:278 - no implicit conversion of Battle::Battler into Integer
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
}
)
Exception `TypeError' at Section151:278 - no implicit conversion of Battle::Battler into Integer