• 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] Ally Switch Causing Error

  • 288
    Posts
    6
    Years
    • Seen Feb 3, 2025
    For some reason, when Ally Switch is used, an error message pops up and the user does not switch places with its partner (its sprite disappears but this may be part of the animation used and not the error). I have not edited the MoveEffects code for Ally Switch, but I must have changed something else that is causing it not to work. Here is the error message:

    [Pokémon Essentials version 17.2]
    Exception: NoMethodError
    Message: undefined method `pbUpdate' for nil:NilClass
    PokeBattle_MoveEffects:1807:in `pbEffect'
    PokeBattle_Battler:5002:in `pbUseMove'
    PokeBattle_Battler:5001:in `logonerr'
    PokeBattle_Battler:5001:in `pbUseMove'
    PokeBattle_Battler:6361:in `pbProcessTurn'
    PokeBattle_Battler:6360:in `logonerr'
    PokeBattle_Battler:6360:in `pbProcessTurn'
    PokeBattle_Battle:4225:in `pbAttackPhase'
    PokeBattle_Battle:4222:in `each'
    PokeBattle_Battle:4222:in `pbAttackPhase'

    This is the code for Ally Switch as present in PokeBattle_MoveEffects:
    Code:
    class PokeBattle_Move_120 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if [email protected] ||
           !attacker.pbPartner || attacker.pbPartner.fainted?
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
        pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
        [email protected][attacker.index]
        [email protected][attacker.pbPartner.index]
        temp=a; a=b; b=temp
        # Swap effects that point at the position rather than the Pokémon
        # NOT PerishSongUser (no need to swap), Attract, MultiTurnUser
        effectstoswap=[PBEffects::BideTarget,
                       PBEffects::CounterTarget,
                       PBEffects::LeechSeed,
                       PBEffects::LockOnPos,
                       PBEffects::MeanLook,
                       PBEffects::MirrorCoatTarget]
        for i in effectstoswap
          a.effects[i],b.effects[i]=b.effects[i],a.effects[i]
        end
        attacker.pbUpdate(true)
        opponent.pbUpdate(true)
        @battle.pbDisplay(_INTL("{1} and {2} switched places!",opponent.pbThis,attacker.pbThis(true)))
      end
    end
     
    Change attacker and opponent to "a" and "b":
    Code:
    a.pbUpdate(true)
    b.pbUpdate(true)

    Also, Ally Switch will be improved in v18, it still has some bug on its script.
     
    Ok so I changed this and it got rid of the error message (I also had to change attacker.pbThis & opponent.pbThis to a & b as well for the battle display text). However, they aren't switching places.

    Also I thought Pokemon Essentials was discontinued and didn't know they were making a v18. I guess they worked out copyright issues now.
     
    Back
    Top