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

[Error] Why is my Caltrops code consistently causing crashes during battle whenever any Pokemon tries using them?

429
Posts
4
Years
  • Code:
    Battle::ItemEffects::OnSwitchIn.add(:CALTROPS,
      proc { |item, user, battler, target, move, battle|
      next    if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3
          user.pbOpposingSide.effects[PBEffects::Spikes] += 1
        battler.pbConsumeItem
      }
    )

    Code:
    Battle::ItemEffects::OnSwitchIn.add(:CALTROPS,
      proc { |item, battler, battle|
      next    if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3
          user.pbOpposingSide.effects[PBEffects::Spikes] += 1
        battle.pbDisplay(_INTL("{1} scatters Caltrops on the foe's side of the field!",
           battler.pbThis, battler.itemName))
      }
    )

    Which version of this code is closer to correct, and what will fix it?

    The goal is for the held item to use Spikes once, and then consume itself, when the Pokemon holding it is sent out.

    Sometimes the error message claims the engine doesn't know what "User" or "Battle" or "Battler" is, and sometimes it claims to not know what "pbOpposingSide" or "PBEffects::Spikes" is.
     
    Last edited:
    1,682
    Posts
    8
    Years
    • Seen yesterday
    The OnSwitchIn Item Effect proc only takes 3 arguments
    Code:
    Battle::ItemEffects::OnSwitchIn.add(:CALTROPS,
      proc { |item, battler, battle|
        next if battler.pbOpposingSide.effects[PBEffects::Spikes] >= 3
        battler.pbOpposingSide.effects[PBEffects::Spikes] += 1
        battle.pbDisplay(_INTL("{1} scatters {2} all around {3}'s feet!",
           battler.pbThis, battler.itemName, battler.pbOpposingTeam(true)))
        battler.pbConsumeItem
      }
    )
     
    Back
    Top