• 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!
  • It's time to vote for your favorite Pokémon Battle Revolution protagonist in our new weekly protagonist poll! Click here to cast your vote and let us know which PBR protagonist you like most.
  • 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?

  • 428
    Posts
    5
    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:
    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