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

Changing Trainer Party order.

12
Posts
8
Years
    • Seen Aug 2, 2023
    Hi all,
    I was wondering if there was a way to set which pokemon a trainer sends out, as when I test the battle, they send out the pokemon I placed to be last as their second pokemon, how Do I go about fixing this?
     
    2
    Posts
    6
    Years
  • Yeah, just go to the script section PokeBattle_AI. Then find "def pbChooseBestNewEnemy(index,party,enemies)"
    And change
    Code:
    def pbChooseBestNewEnemy(index,party,enemies)
        return -1 if !enemies || enemies.length==0
        $PokemonTemp=PokemonTemp.new if !$PokemonTemp
        o1=@battlers[index].pbOpposing1
        o2=@battlers[index].pbOpposing2
        o1=nil if o1 && o1.fainted?
        o2=nil if o2 && o2.fainted?
        best=-1
        bestSum=0
        for e in enemies
          pkmn=party[e]
          sum=0
          for move in pkmn.moves
            next if move.id==0
            md=PBMoveData.new(move.id)
            next if md.basedamage==0
            if o1
              sum+=PBTypes.getCombinedEffectiveness(md.type,o1.type1,o1.type2,o1.effects[PBEffects::Type3])
            end
            if o2
              sum+=PBTypes.getCombinedEffectiveness(md.type,o2.type1,o2.type2,o2.effects[PBEffects::Type3])
            end
          end
          if best==-1 || sum>bestSum
            best=e
            bestSum=sum
          end
        end
        return best
      end
    To this:
    Code:
    def pbChooseBestNewEnemy(index,party,enemies)
        return -1 if !enemies || enemies.length==0
        $PokemonTemp=PokemonTemp.new if !$PokemonTemp
        o1=@battlers[index].pbOpposing1
        o2=@battlers[index].pbOpposing2
        o1=nil if o1 && o1.fainted?
        o2=nil if o2 && o2.fainted?
        best=-1
        bestSum=0
        for e in enemies
          pkmn=party[e]
          sum=0
          for move in pkmn.moves
            next
          end
          if best==-1 || sum>bestSum
            best=e
            bestSum=sum
          end
        end
        return best
      end

    Basically that just removes the few lines of code that tell the AI to use their best Pokemon rather than their next one.
    And... that should work. I tested this in the latest version of Essentials and it worked fine.
     
    Back
    Top