• 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] undefined method pbTryUseMove when using a move

  • 5
    Posts
    5
    Years
    • Seen Mar 13, 2021
    Errors are tied to an undefined method of 'pbTryUseMove' in PokeBattle_Battler, which doesn't make sense as it's defined before it's called, and PokeBattle_Battle.

    I've only added certain effects attributed to Gen VII abilities and attacks since I began poking around in Essentials. I can post code if needed.

    This error occurs whenever a Pokemon tries to attack / use a move, and prevents it from happening.
    Code:
    Exception: NoMethodError
    
    Message: undefined method `pbTryUseMove' for #<PokeBattle_Battler:0xddcd580>
    PokeBattle_Battler:3209:in `pbUseMove'
    PokeBattle_Battler:3618:in `pbProcessTurn'
    PokeBattle_Battler:3617:in `logonerr'
    PokeBattle_Battler:3617:in `pbProcessTurn'
    PokeBattle_Battle:2847:in `pbAttackPhase'
    PokeBattle_Battle:2844:in `each'
    PokeBattle_Battle:2844:in `pbAttackPhase'
    PokeBattle_Battle:2832:in `times'
    PokeBattle_Battle:2832:in `pbAttackPhase'
    PokeBattle_Battle:2547:in `pbStartBattleCore'
     
    What did you add about gen VII codes?
     
    Full code of each section mentioned:

    UseMove (line 3209 in Battler)
    Code:
      def pbUseMove(choice,specialusage=false)
        # TODO: lastMoveUsed is not to be updated on nested calls
        # Note: user.lastMoveUsedType IS to be updated on nested calls; is used for Conversion 2
        turneffects=[]
        turneffects[PBEffects::SpecialUsage]=specialusage
        turneffects[PBEffects::SkipAccuracyCheck]=(specialusage && choice[2][email protected])
        turneffects[PBEffects::PassedTrying]=false
        turneffects[PBEffects::TotalDamage]=0
        # Start using the move
        pbBeginTurn(choice)
        # Force the use of certain moves if they're already being used
        if @effects[PBEffects::TwoTurnAttack]>0 ||
           @effects[PBEffects::HyperBeam]>0 ||
           @effects[PBEffects::Outrage]>0 ||
           @effects[PBEffects::Rollout]>0 ||
           @effects[PBEffects::Uproar]>0 ||
           @effects[PBEffects::Bide]>0
          choice[2]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(@currentMove))
          turneffects[PBEffects::SpecialUsage]=true
          PBDebug.log("Continuing multi-turn move #{choice[2].name}")
        elsif @effects[PBEffects::Encore]>0 && choice[1]>=0
          if @battle.pbCanShowCommands?(@index) &&
             @battle.pbCanChooseMove?(@index,@effects[PBEffects::EncoreIndex],false)
            if choice[1]!=@effects[PBEffects::EncoreIndex] # Was Encored mid-round
              choice[1]=@effects[PBEffects::EncoreIndex]
              choice[2]=@moves[@effects[PBEffects::EncoreIndex]]
              choice[3]=-1 # No target chosen
            end
            PBDebug.log("Using Encored move #{choice[2].name}")
          end
        end
        thismove=choice[2]
        return if !thismove || thismove.id==0   # if move was not chosen
        if !turneffects[PBEffects::SpecialUsage]
          # TODO: Quick Claw message
        end
        # Stance Change
        if hasWorkingAbility(:STANCECHANGE) && isConst?(species,PBSpecies,:AEGISLASH) &&
           !@effects[PBEffects::Transform]
          if thismove.pbIsDamaging? && self.form!=1
            self.form=1
            pbUpdate(true)
            @battle.scene.pbChangePokemon(self,@pokemon)
            @battle.pbDisplay(_INTL("{1} changed to Blade Forme!",pbThis))
            PBDebug.log("[Form changed] #{pbThis} changed to Blade Forme")
          elsif isConst?(thismove.id,PBMoves,:KINGSSHIELD) && self.form!=0
            self.form=0
            pbUpdate(true)
            @battle.scene.pbChangePokemon(self,@pokemon)
            @battle.pbDisplay(_INTL("{1} changed to Shield Forme!",pbThis))
            PBDebug.log("[Form changed] #{pbThis} changed to Shield Forme")
          end      
        end
        # Record that user has used a move this round (ot at least tried to)
        [email protected]
        # Try to use the move
        if !pbTryUseMove(choice,thismove,turneffects)
          self.lastMoveUsed=-1
          self.lastMoveUsedType=-1
          if !turneffects[PBEffects::SpecialUsage]
            self.lastMoveUsedSketch=-1 if self.effects[PBEffects::TwoTurnAttack]==0
            self.lastRegularMoveUsed=-1
          end
          pbCancelMoves
          @battle.pbGainEXP
          pbEndTurn(choice)
          @battle.pbJudge #      @battle.pbSwitch
          return
        end
        thismove=choice[2]   # Disobedience may have changed the move to be used
        return if !thismove || thismove.id==0   # if move was not chosen
        if !turneffects[PBEffects::SpecialUsage]
          if !pbReducePP(thismove)
            @battle.pbDisplay(_INTL("{1} used\r\n{2}!",pbThis,thismove.name))
            @battle.pbDisplay(_INTL("But there was no PP left for the move!"))
            self.lastMoveUsed=-1
            self.lastMoveUsedType=-1
            self.lastMoveUsedSketch=-1 if self.effects[PBEffects::TwoTurnAttack]==0
            self.lastRegularMoveUsed=-1
            pbEndTurn(choice)
            @battle.pbJudge #        @battle.pbSwitch
            PBDebug.log("[Move failed] #{thismove.name} has no PP left")
            return
          end
        end
        # Remember that user chose a two-turn move
        if thismove.pbTwoTurnAttack(self)
          # Beginning use of two-turn attack
          @effects[PBEffects::TwoTurnAttack]=thismove.id
          @currentMove=thismove.id
        else
          @effects[PBEffects::TwoTurnAttack]=0 # Cancel use of two-turn attack
        end
        # Charge up Metronome item
        if self.lastMoveUsed==thismove.id
          self.effects[PBEffects::Metronome]+=1
        else
          self.effects[PBEffects::Metronome]=0
        end
        # "X used Y!" message
        case thismove.pbDisplayUseMessage(self)
        when 2   # Continuing Bide
          return
        when 1   # Starting Bide
          self.lastMoveUsed=thismove.id
          self.lastMoveUsedType=thismove.pbType(thismove.type,self,nil)
          if !turneffects[PBEffects::SpecialUsage]
            self.lastMoveUsedSketch=thismove.id if self.effects[PBEffects::TwoTurnAttack]==0
            self.lastRegularMoveUsed=thismove.id
          end
          @battle.lastMoveUsed=thismove.id
          @battle.lastMoveUser=self.index
          @battle.successStates[self.index].useState=2
          @battle.successStates[self.index].typemod=8
          return
        when -1   # Was hurt while readying Focus Punch, fails use
          self.lastMoveUsed=thismove.id
          self.lastMoveUsedType=thismove.pbType(thismove.type,self,nil)
          if !turneffects[PBEffects::SpecialUsage]
            self.lastMoveUsedSketch=thismove.id if self.effects[PBEffects::TwoTurnAttack]==0
            self.lastRegularMoveUsed=thismove.id
          end
          @battle.lastMoveUsed=thismove.id
          @battle.lastMoveUser=self.index
          @battle.successStates[self.index].useState=2 # somehow treated as a success
          @battle.successStates[self.index].typemod=8
          PBDebug.log("[Move failed] #{pbThis} was hurt while readying Focus Punch")
          return
        end
        # Find the user and target(s)
        targets=[]
        user=pbFindUser(choice,targets)
        # Battle Arena only - assume failure 
        @battle.successStates[user.index].useState=1
        @battle.successStates[user.index].typemod=8
        # Check whether Selfdestruct works
        if !thismove.pbOnStartUse(user) # Selfdestruct, Natural Gift, Beat Up can return false here
          PBDebug.log(sprintf("[Move failed] Failed pbOnStartUse (function code %02X)",thismove.function))
          user.lastMoveUsed=thismove.id
          user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
          if !turneffects[PBEffects::SpecialUsage]
            user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
            user.lastRegularMoveUsed=thismove.id
          end
          @battle.lastMoveUsed=thismove.id
          @battle.lastMoveUser=user.index
          return
        end
        # Primordial Sea, Desolate Land
        if thismove.pbIsDamaging?
          case @battle.pbWeather
          when PBWeather::HEAVYRAIN
            if isConst?(thismove.pbType(thismove.type,user,nil),PBTypes,:FIRE)
              PBDebug.log("[Move failed] Primordial Sea's rain cancelled the Fire-type #{thismove.name}")
              @battle.pbDisplay(_INTL("The Fire-type attack fizzled out in the heavy rain!"))
              user.lastMoveUsed=thismove.id
              user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
              if !turneffects[PBEffects::SpecialUsage]
                user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
                user.lastRegularMoveUsed=thismove.id
              end
              @battle.lastMoveUsed=thismove.id
              @battle.lastMoveUser=user.index
              return
            end
          when PBWeather::HARSHSUN
            if isConst?(thismove.pbType(thismove.type,user,nil),PBTypes,:WATER)
              PBDebug.log("[Move failed] Desolate Land's sun cancelled the Water-type #{thismove.name}")
              @battle.pbDisplay(_INTL("The Water-type attack evaporated in the harsh sunlight!"))
              user.lastMoveUsed=thismove.id
              user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
              if !turneffects[PBEffects::SpecialUsage]
                user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
                user.lastRegularMoveUsed=thismove.id
              end
              @battle.lastMoveUsed=thismove.id
              @battle.lastMoveUser=user.index
              return
            end
          end
        end
        # Powder
        if user.effects[PBEffects::Powder] && isConst?(thismove.pbType(thismove.type,user,nil),PBTypes,:FIRE)
          PBDebug.log("[Lingering effect triggered] #{pbThis}'s Powder cancelled the Fire move")
          @battle.pbCommonAnimation("Powder",user,nil)
          @battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!"))
          user.pbReduceHP(1+(user.totalhp/4).floor) if !user.hasWorkingAbility(:MAGICGUARD)   
          user.lastMoveUsed=thismove.id
          user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
          if !turneffects[PBEffects::SpecialUsage]
            user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
            user.lastRegularMoveUsed=thismove.id
          end
          @battle.lastMoveUsed=thismove.id
          @battle.lastMoveUser=user.index
          user.pbFaint if user.fainted?
          pbEndTurn(choice)
          return
        end
        # Protean
        if user.hasWorkingAbility(:PROTEAN) &&
           thismove.function!=0xAE &&   # Mirror Move
           thismove.function!=0xAF &&   # Copycat
           thismove.function!=0xB0 &&   # Me First
           thismove.function!=0xB3 &&   # Nature Power
           thismove.function!=0xB4 &&   # Sleep Talk
           thismove.function!=0xB5 &&   # Assist
           thismove.function!=0xB6      # Metronome
          movetype=thismove.pbType(thismove.type,user,nil)
          if !user.pbHasType?(movetype)
            typename=PBTypes.getName(movetype)
            PBDebug.log("[Ability triggered] #{pbThis}'s Protean made it #{typename}-type")
            user.type1=movetype
            user.type2=movetype
            user.effects[PBEffects::Type3]=-1
            @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",user.pbThis,typename))  
          end
        end
        # Try to use move against user if there aren't any targets
        if targets.length==0
          user=pbChangeUser(thismove,user)
          if thismove.target==PBTargets::SingleNonUser ||
             thismove.target==PBTargets::RandomOpposing ||
             thismove.target==PBTargets::AllOpposing ||
             thismove.target==PBTargets::AllNonUsers ||
             thismove.target==PBTargets::Partner ||
             thismove.target==PBTargets::UserOrPartner ||
             thismove.target==PBTargets::SingleOpposing ||
             thismove.target==PBTargets::OppositeOpposing
            @battle.pbDisplay(_INTL("But there was no target..."))
          else
            PBDebug.logonerr{
               thismove.pbEffect(user,nil)
            }
          end
        else
          # We have targets
          showanimation=true
          alltargets=[]
          for i in 0...targets.length
            alltargets.push(targets[i].index) if !targets.include?(targets[i].index)
          end
          # For each target in turn
          i=0; loop do break if i>=targets.length
            # Get next target
            userandtarget=[user,targets[i]]
            success=pbChangeTarget(thismove,userandtarget,targets)
            user=userandtarget[0]
            target=userandtarget[1]
            if i==0 && thismove.target==PBTargets::AllOpposing
              # Add target's partner to list of targets
              pbAddTarget(targets,target.pbPartner)
            end
            # If couldn't get the next target
            if !success
              i+=1
              next
            end
            # Get the number of hits
            numhits=thismove.pbNumHits(user)
            # Reset damage state, set Focus Band/Focus Sash to available
            target.damagestate.reset
            # Use move against the current target
            pbProcessMoveAgainstTarget(thismove,user,target,numhits,turneffects,false,alltargets,showanimation)
            showanimation=false
            i+=1
          end
        end
        # Pokémon switching caused by Roar, Whirlwind, Circle Throw, Dragon Tail, Red Card
        if !user.fainted?
          switched=[]
          for i in 0...4
            if @battle.battlers[i].effects[PBEffects::Roar]
              @battle.battlers[i].effects[PBEffects::Roar]=false
              @battle.battlers[i].effects[PBEffects::Uturn]=false
              next if @battle.battlers[i].fainted?
              next if [email protected]?(i,-1,false)
              choices=[]
              [email protected](i)
              for j in 0...party.length
                choices.push(j) if @battle.pbCanSwitchLax?(i,j,false)
              end
              if choices.length>0
                newpoke=choices[@battle.pbRandom(choices.length)]
                newpokename=newpoke
                if isConst?(party[newpoke].ability,PBAbilities,:ILLUSION)
                  newpokename=pbGetLastPokeInTeam(i)
                end
                switched.push(i)
                @battle.battlers[i].pbResetUsualForms
                @battle.pbRecallAndReplace(i,newpoke,newpokename,false,user.hasMoldBreaker ||
                thismove.doesBypassIgnorableAbilities?)
                @battle.pbDisplay(_INTL("{1} was dragged out!",@battle.battlers[i].pbThis))
                @battle.choices[i]=[0,0,nil,-1]   # Replacement Pokémon does nothing this round
              end
            end
          end
          for i in @battle.pbPriority
            next if !switched.include?(i.index)
            i.pbAbilitiesOnSwitchIn(true)
          end
        end
        # Pokémon switching caused by U-Turn, Volt Switch, Eject Button
        switched=[]
        for i in 0...4
          if @battle.battlers[i].effects[PBEffects::Uturn]
            @battle.battlers[i].effects[PBEffects::Uturn]=false
            @battle.battlers[i].effects[PBEffects::Roar]=false
            if [email protected][i].fainted? && @battle.pbCanChooseNonActive?(i) &&
               [email protected]?(@battle.pbOpposingParty(i))
              # TODO: Pursuit should go here, and negate this effect if it KO's attacker
              @battle.pbDisplay(_INTL("{1} went back to {2}!",@battle.battlers[i].pbThis,@battle.pbGetOwner(i).name))
              newpoke=0
              [email protected](i,true,false)
              newpokename=newpoke
              if isConst?(@battle.pbParty(i)[newpoke].ability,PBAbilities,:ILLUSION)
                newpokename=pbGetLastPokeInTeam(i)
              end
              switched.push(i)
              @battle.battlers[i].pbResetForm
              @battle.pbRecallAndReplace(i,newpoke,newpokename,@battle.battlers[i].effects[PBEffects::BatonPass])
              @battle.choices[i]=[0,0,nil,-1]   # Replacement Pokémon does nothing this round
            end
          end
        end
        for i in @battle.pbPriority
          next if !switched.include?(i.index)
          i.pbAbilitiesOnSwitchIn(true)
        end
        # Baton Pass
        if user.effects[PBEffects::BatonPass]
          user.effects[PBEffects::BatonPass]=false
          if !user.fainted? && @battle.pbCanChooseNonActive?(user.index) &&
             [email protected]?(@battle.pbParty(user.index))
            newpoke=0
            [email protected](user.index,true,false)
            newpokename=newpoke
            if isConst?(@battle.pbParty(user.index)[newpoke].ability,PBAbilities,:ILLUSION)
              newpokename=pbGetLastPokeInTeam(user.index)
            end
            user.pbResetForm
            @battle.pbRecallAndReplace(user.index,newpoke,newpokename,true)
            @battle.choices[user.index]=[0,0,nil,-1]   # Replacement Pokémon does nothing this round
            user.pbAbilitiesOnSwitchIn(true)
          end
        end
        # Record move as having been used
        user.lastMoveUsed=thismove.id
        user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
        if !turneffects[PBEffects::SpecialUsage]
          user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
          user.lastRegularMoveUsed=thismove.id
          user.movesUsed.push(thismove.id) if !user.movesUsed.include?(thismove.id) # For Last Resort
        end
        @battle.lastMoveUsed=thismove.id
        @battle.lastMoveUser=user.index
        # Gain Exp
        @battle.pbGainEXP
        # Battle Arena only - update skills
        for i in 0...4
          @battle.successStates[i].updateSkill
        end
        # End of move usage
        pbEndTurn(choice)
        @battle.pbJudge #    @battle.pbSwitch
        return
      end

    ProcessTurn and logonerr (line 3617-18 in Battler)
    Code:
      def pbProcessTurn(choice)
        # Can't use a move if fainted
        return false if fainted?
        # Wild roaming Pokémon always flee if possible
        if [email protected] && @battle.pbIsOpposing?(self.index) &&
           @battle.rules["alwaysflee"] && @battle.pbCanRun?(self.index)
          pbBeginTurn(choice)
          @battle.pbDisplay(_INTL("{1} fled!",self.pbThis))
          @battle.decision=3
          pbEndTurn(choice)
          PBDebug.log("[Escape] #{pbThis} fled")
          return true
        end
        # If this battler's action for this round wasn't "use a move"
        if choice[0]!=1
          # Clean up effects that end at battler's turn
          pbBeginTurn(choice)
          pbEndTurn(choice)
          return false
        end
        # Turn is skipped if Pursuit was used during switch
        if @effects[PBEffects::Pursuit]
          @effects[PBEffects::Pursuit]=false
          pbCancelMoves
          pbEndTurn(choice)
          @battle.pbJudge #      @battle.pbSwitch
          return false
        end
        # Use the move
    #   @battle.pbDisplayPaused("Before: [#{@lastMoveUsedSketch},#{@lastMoveUsed}]")
        PBDebug.log("#{pbThis} used #{choice[2].name}")
        PBDebug.logonerr{
           pbUseMove(choice,choice[2][email protected])
        }
    #   @battle.pbDisplayPaused("After: [#{@lastMoveUsedSketch},#{@lastMoveUsed}]")
        return true
      end

    AttackPhase (line 2832-47 in Battle)
    Code:
    def pbAttackPhase
        @scene.pbBeginAttackPhase
        for i in 0...4
          @successStates[i].clear
          if @choices[i][0]!=1 && @choices[i][0]!=2
            @battlers[i].effects[PBEffects::DestinyBond]=false
            @battlers[i].effects[PBEffects::Grudge]=false
          end
          @battlers[i].turncount+=1 if !@battlers[i].fainted?
          @battlers[i].effects[PBEffects::Rage]=false if !pbChoseMove?(i,:RAGE)
        end
        # Calculate priority at this time
        @usepriority=false
        priority=pbPriority(false,true)
        # Mega Evolution
        megaevolved=[]
        for i in priority
          if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
            side=(pbIsOpposing?(i.index)) ? 1 : 0
            owner=pbGetOwnerIndex(i.index)
            if @megaEvolution[side][owner]==i.index
              pbMegaEvolve(i.index)
              megaevolved.push(i.index)
            end
          end
        end
        if megaevolved.length>0
          for i in priority
            i.pbAbilitiesOnSwitchIn(true) if megaevolved.include?(i.index)
          end
        end
        # Call at Pokémon
        for i in priority
          if @choices[i.index][0]==4 && !i.effects[PBEffects::SkipTurn]
            pbCall(i.index)
          end
        end
        # Switch out Pokémon
        @switching=true
        switched=[]
        for i in priority
          if @choices[i.index][0]==2 && !i.effects[PBEffects::SkipTurn]
            index=@choices[i.index][1] # party position of Pokémon to switch to
            newpokename=index
            if isConst?(pbParty(i.index)[index].ability,PBAbilities,:ILLUSION)
              newpokename=pbGetLastPokeInTeam(i.index)
            end
            self.lastMoveUser=i.index
            if !pbOwnedByPlayer?(i.index)
              owner=pbGetOwner(i.index)
              pbDisplayBrief(_INTL("{1} withdrew {2}!",owner.fullname,i.name))
              PBDebug.log("[Withdrew Pokémon] Opponent withdrew #{i.pbThis(true)}")
            else
              pbDisplayBrief(_INTL("{1}, that's enough!\r\nCome back!",i.name))
              PBDebug.log("[Withdrew Pokémon] Player withdrew #{i.pbThis(true)}")
            end
            for j in priority
              next if !i.pbIsOpposing?(j.index)
              # if Pursuit and this target ("i") was chosen
              if pbChoseMoveFunctionCode?(j.index,0x88) && # Pursuit
                 !j.hasMovedThisRound?
                if j.status!=PBStatuses::SLEEP && j.status!=PBStatuses::FROZEN &&
                   !j.effects[PBEffects::SkyDrop] &&
                   (!j.hasWorkingAbility(:TRUANT) || !j.effects[PBEffects::Truant])
                  @choices[j.index][3]=i.index # Make sure to target the switching Pokémon
                  j.pbUseMove(@choices[j.index]) # This calls pbGainEXP as appropriate
                  j.effects[PBEffects::Pursuit]=true
                  @switching=false
                  return if @decision>0
                end
              end
              break if i.fainted?
            end
            if !pbRecallAndReplace(i.index,index,newpokename)
              # If a forced switch somehow occurs here in single battles
              # the attack phase now ends
              if !@doublebattle
                @switching=false
                return
              end
            else
              switched.push(i.index)
            end
          end
        end
        if switched.length>0
          for i in priority
            i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
          end
        end
        @switching=false
        # Use items
        for i in priority
          if @choices[i.index][0]==3 && !i.effects[PBEffects::SkipTurn]
            if pbIsOpposing?(i.index)
              # Opponent use item
              pbEnemyUseItem(@choices[i.index][1],i)
            else
              # Player use item
              item=@choices[i.index][1]
              if item>0
                usetype=$ItemData[item][ITEMBATTLEUSE]
                if usetype==1 || usetype==3
                  if @choices[i.index][2]>=0
                    pbUseItemOnPokemon(item,@choices[i.index][2],i,@scene)
                  end
                elsif usetype==2 || usetype==4
                  if !ItemHandlers.hasUseInBattle(item) # Poké Ball/Poké Doll used already
                    pbUseItemOnBattler(item,@choices[i.index][2],i,@scene)
                  end
                end
              end
            end
          end
        end
        # Use attacks
        for i in priority
          next if i.effects[PBEffects::SkipTurn]
          if pbChoseMoveFunctionCode?(i.index,0x115) # Focus Punch
            pbCommonAnimation("FocusPunch",i,nil)
            pbDisplay(_INTL("{1} is tightening its focus!",i.pbThis))
          elsif pbChoseMoveFunctionCode?(i.index,0xCF20) # Beak Blast
            pbCommonAnimation("Burn",i,nil)
            pbDisplay(_INTL("{1} started heating up its beak!",i.pbThis))
          end
        end
        10.times do
          # Forced to go next
          advance=false
          for i in priority
            next if !i.effects[PBEffects::MoveNext]
            next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
            advance=i.pbProcessTurn(@choices[i.index])
            break if advance
          end
          return if @decision>0
          next if advance
          # Regular priority order
          for i in priority
            next if i.effects[PBEffects::Quash]
            next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
            advance=i.pbProcessTurn(@choices[i.index])
            break if advance
          end
          return if @decision>0
          next if advance
          # Quashed
          for i in priority
            next if !i.effects[PBEffects::Quash]
            next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
            advance=i.pbProcessTurn(@choices[i.index])
            break if advance
          end
          return if @decision>0
          next if advance
          # Check for all done
          for i in priority
            advance=true if @choices[i.index][0]==1 && !i.hasMovedThisRound? &&
                            !i.effects[PBEffects::SkipTurn]
            break if advance
          end
          next if advance
          break
        end
        10.times do
          @scene.pbGraphicsUpdate
          @scene.pbInputUpdate
          @scene.pbFrameUpdate
        end
      end

    Initialize battle (line 2547 in Battle)
    Code:
        if @weather==PBWeather::SUNNYDAY
          pbCommonAnimation("Sunny",nil,nil)
          pbDisplay(_INTL("The sunlight is strong."))
        elsif @weather==PBWeather::RAINDANCE
          pbCommonAnimation("Rain",nil,nil)
          pbDisplay(_INTL("It is raining."))
        elsif @weather==PBWeather::SANDSTORM
          pbCommonAnimation("Sandstorm",nil,nil)
          pbDisplay(_INTL("A sandstorm is raging."))
        elsif @weather==PBWeather::HAIL
          pbCommonAnimation("Hail",nil,nil)
          pbDisplay(_INTL("Hail is falling."))
        elsif @weather==PBWeather::HEAVYRAIN
          pbCommonAnimation("HeavyRain",nil,nil)
          pbDisplay(_INTL("It is raining heavily."))
        elsif @weather==PBWeather::HARSHSUN
          pbCommonAnimation("HarshSun",nil,nil)
          pbDisplay(_INTL("The sunlight is extremely harsh."))
        elsif @weather==PBWeather::STRONGWINDS
          pbCommonAnimation("StrongWinds",nil,nil)
          pbDisplay(_INTL("The wind is strong."))
        end
        pbOnActiveAll   # Abilities
        @turncount=0
        loop do   # Now begin the battle loop
          PBDebug.log("")
          PBDebug.log("***Round #{@turncount+1}***")
          if @debug && @turncount>=100
            @decision=pbDecisionOnTime()
            PBDebug.log("")
            PBDebug.log("***Undecided after 100 rounds, aborting***")
            pbAbort
            break
          end
          PBDebug.logonerr{
             pbCommandPhase
          }
          break if @decision>0
          PBDebug.logonerr{
             pbAttackPhase
          }
          break if @decision>0
          PBDebug.logonerr{
             pbEndOfRoundPhase
          }
          break if @decision>0
          @turncount+=1
        end
        return pbEndOfBattle(canlose)
      end

    And, finally, def pbTryUseMove itself (beginning on line 2754 in Battler)
    Code:
    def pbTryUseMove(choice,thismove,turneffects)
        return true if turneffects[PBEffects::PassedTrying]
        # TODO: Return true if attack has been Mirror Coated once already
        if @effects[PBEffects::SkyDrop] # Intentionally no message here
          PBDebug.log("[Move failed] #{pbThis} can't use #{thismove.name} because of being Sky Dropped")
          return false
        end
        if @battle.field.effects[PBEffects::Gravity]>0 && thismove.unusableInGravity?
          @battle.pbDisplay(_INTL("{1} can't use {2} because of gravity!",pbThis,thismove.name))
          PBDebug.log("[Move failed] #{pbThis} can't use #{thismove.name} because of Gravity")
          return false
        end
        if @effects[PBEffects::Taunt]>0 && thismove.basedamage==0
          @battle.pbDisplay(_INTL("{1} can't use {2} after the taunt!",pbThis,thismove.name))
          PBDebug.log("[Move failed] #{pbThis} can't use #{thismove.name} because of Taunt")
          return false
        end
        if @effects[PBEffects::HealBlock]>0 && thismove.isHealingMove?
          @battle.pbDisplay(_INTL("{1} can't use {2} because of Heal Block!",pbThis,thismove.name))
          PBDebug.log("[Move failed] #{pbThis} can't use #{thismove.name} because of Heal Block")
          return false
        end
        if @effects[PBEffects::Torment] && thismove.id==@lastMoveUsed &&
           [email protected] && @effects[PBEffects::TwoTurnAttack]==0
          @battle.pbDisplayPaused(_INTL("{1} can't use the same move in a row due to the torment!",pbThis))
          PBDebug.log("[Move failed] #{pbThis} can't use #{thismove.name} because of Torment")
          return false
        end
        if pbOpposing1.effects[PBEffects::Imprison] && !pbOpposing1.fainted?
          if thismove.id==pbOpposing1.moves[0].id ||
             thismove.id==pbOpposing1.moves[1].id ||
             thismove.id==pbOpposing1.moves[2].id ||
             thismove.id==pbOpposing1.moves[3].id
            @battle.pbDisplay(_INTL("{1} can't use the sealed {2}!",pbThis,thismove.name))
            PBDebug.log("[Move failed] #{thismove.name} can't use #{thismove.name} because of #{pbOpposing1.pbThis(true)}'s Imprison")
            return false
          end
        end
        if pbOpposing2.effects[PBEffects::Imprison] && !pbOpposing2.fainted?
          if thismove.id==pbOpposing2.moves[0].id ||
             thismove.id==pbOpposing2.moves[1].id ||
             thismove.id==pbOpposing2.moves[2].id ||
             thismove.id==pbOpposing2.moves[3].id
            @battle.pbDisplay(_INTL("{1} can't use the sealed {2}!",pbThis,thismove.name))
            PBDebug.log("[Move failed] #{thismove.name} can't use #{thismove.name} because of #{pbOpposing2.pbThis(true)}'s Imprison")
            return false
          end
        end
        if @effects[PBEffects::ThroatChop]>0 && !pbOpposing1.fainted?
          if thismove.isSoundBased?
            @battle.pbDisplay(_INTL("{1} can't use {2} because they were hushed!",pbThis,thismove.name))
            PBDebug.log("[Move failed] #{pbThis} can't use #{thismove.name} because of #{pbOpposing2.pbThis(true)}'s Throat Chop")
            return false
          end
        end
        if @effects[PBEffects::Disable]>0 && thismove.id==@effects[PBEffects::DisableMove] &&
           [email protected] # Pursuit ignores if it's disabled
          @battle.pbDisplayPaused(_INTL("{1}'s {2} is disabled!",pbThis,thismove.name))
          PBDebug.log("[Move failed] #{pbThis}'s #{thismove.name} is disabled")
          return false
        end
        if choice[1]==-2 # Battle Palace
          @battle.pbDisplay(_INTL("{1} appears incapable of using its power!",pbThis))
          PBDebug.log("[Move failed] Battle Palace: #{pbThis} is incapable of using its power")
          return false
        end
        if @effects[PBEffects::HyperBeam]>0
          @battle.pbDisplay(_INTL("{1} must recharge!",pbThis))
          PBDebug.log("[Move failed] #{pbThis} must recharge after using #{PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(@currentMove)).name}")
          return false
        end
        if self.hasWorkingAbility(:TRUANT) && @effects[PBEffects::Truant]
          @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
          PBDebug.log("[Ability triggered] #{pbThis}'s Truant")
          return false
        end
        if !turneffects[PBEffects::SkipAccuracyCheck]
          if self.status==PBStatuses::SLEEP
            self.statusCount-=1
            if self.statusCount<=0
              self.pbCureStatus
            else
              self.pbContinueStatus
              PBDebug.log("[Status] #{pbThis} remained asleep (count: #{self.statusCount})")
              if !thismove.pbCanUseWhileAsleep? # Snore/Sleep Talk/Outrage
                PBDebug.log("[Move failed] #{pbThis} couldn't use #{thismove.name} while asleep")
                return false
              end
            end
          end
        end
        if self.status==PBStatuses::FROZEN
          if thismove.canThawUser?
            PBDebug.log("[Move effect triggered] #{pbThis} was defrosted by using #{thismove.name}")
            self.pbCureStatus(false)
            @battle.pbDisplay(_INTL("{1} melted the ice!",pbThis))
            pbCheckForm
          elsif @battle.pbRandom(10)<2 && !turneffects[PBEffects::SkipAccuracyCheck]
            self.pbCureStatus
            pbCheckForm
          elsif !thismove.canThawUser?
            self.pbContinueStatus
            PBDebug.log("[Status] #{pbThis} remained frozen and couldn't move")
            return false
          end
        end
        if !turneffects[PBEffects::SkipAccuracyCheck]
          if @effects[PBEffects::Confusion]>0
            @effects[PBEffects::Confusion]-=1
            if @effects[PBEffects::Confusion]<=0
              pbCureConfusion
            else
              pbContinueConfusion
              PBDebug.log("[Status] #{pbThis} remained confused (count: #{@effects[PBEffects::Confusion]})")
              if @battle.pbRandom(2)==0
                pbConfusionDamage
                @battle.pbDisplay(_INTL("It hurt itself in its confusion!")) 
                PBDebug.log("[Status] #{pbThis} hurt itself in its confusion and couldn't move")
                return false
              end
            end
          end
        end
        if @effects[PBEffects::Flinch]
          @effects[PBEffects::Flinch]=false
          @battle.pbDisplay(_INTL("{1} flinched and couldn't move!",self.pbThis))
          PBDebug.log("[Lingering effect triggered] #{pbThis} flinched")
          if self.hasWorkingAbility(:STEADFAST)
            if pbIncreaseStatWithCause(PBStats::SPEED,1,self,PBAbilities.getName(self.ability))
              PBDebug.log("[Ability triggered] #{pbThis}'s Steadfast")
            end
          end
          return false
        end
        if !turneffects[PBEffects::SkipAccuracyCheck]
          if @effects[PBEffects::Attract]>=0
            pbAnnounceAttract(@battle.battlers[@effects[PBEffects::Attract]])
            if @battle.pbRandom(2)==0
              pbContinueAttract
              PBDebug.log("[Lingering effect triggered] #{pbThis} was infatuated and couldn't move")
              return false
            end
          end
          if self.status==PBStatuses::PARALYSIS
            if @battle.pbRandom(4)==0
              pbContinueStatus
              PBDebug.log("[Status] #{pbThis} was fully paralysed and couldn't move")
              return false
            end
          end
        end
        if !turneffects[PBEffects::SkipAccuracyCheck]
          return false if !pbObedienceCheck?(choice)
        end
        turneffects[PBEffects::PassedTrying]=true
        return true
      end

    I don't believe I've pasted anything into the wrong section of code. Maybe I have and I should start over. Who knows.
     
    Identified one error and solved it (Beak Blast referring to the wrong function code), but it did not fix the glitch as a whole.
     
    The new things I do remember pasting in are Burn Up, Surge abilities, Baneful Bunker, Laser Focus, Throat Chop, Stomping Tantrum, Aurora Veil, Plasma Fists, Triage (maybe), Core Enforcer, the Alolan Legendary signature effect (ignoring abilities upon using the move in question), Shell Trap, Spectral Thief, Mind Blown, Wimp Out/Emergency Exit, Water Compaction, Beast Boost, Multitype and Multi-Attack.

    I also added in No Retreat for Falinks, but I doubt that that has any relevance.
     
    Back
    Top