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

3 Pokemon Selection for Trainers

Rayd12smitty

Shadow Maker
645
Posts
12
Years
    • Seen Feb 21, 2016
    THE SCRIPT IS FIXED :D


    If you've played BW2 you know about the Pokemon World Tournament. In this tournament, you select 3 pokemon to enter, and then challenge different trainers, who use a random combination of 3 pokemon, out of their 6. Every trainer has 6 possible pokemon they could use, and they all pick 3.

    Using FL's Pokemon Selection script, you can make the player select 3 pokemon. I wanted to make it so that when a certain switch is on, opposing trainers randomly select 3 of their 6 pokemon to use against you. This way there is more variety to the battles. Insert this script in the script section PokemonTrainers
    Code:
    #=============================================================================== 
    # * This script checks if the enemy trainer should randomly select 3 of their
    #   6 pokemon to use in the battle. Recommended to be used with FL's
    #   Pokemon Selection script to add more variety to battles.
    # * Script by Rayd12smitty. Public for use, but please give credit.
    # * Replace "for poke in trainer[3]" in the script section "PokemonTrainers
    #   with this script.
    # * To use the script, before a battle, set the switch of your choice
    #         $game_switches[XXX] = true
    # * Remember to use
    #         $game_switches[XXX] = false
    #   after the battle so future battles don't use this.
    #
    # * NOTE - The trainers data still goes in "trainers.txt" like normal. The
    #   trainer must have 6 pokemon listed for this to work.
    #===============================================================================
        if $game_switches[XXX]==true
          $TrainersPokeSelection = rand(20)+1
          $TrainersPokeSelectionCheck = 1
          for poke in trainer[3]
            if $TrainersPokeSelection==1 and $TrainersPokeSelectionCheck==4
            elsif $TrainersPokeSelection==1 and $TrainersPokeSelectionCheck==5
            elsif $TrainersPokeSelection==1 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==2 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==2 and $TrainersPokeSelectionCheck==5
            elsif $TrainersPokeSelection==2 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==3 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==3 and $TrainersPokeSelectionCheck==4
            elsif $TrainersPokeSelection==3 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==4 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==4 and $TrainersPokeSelectionCheck==4
            elsif $TrainersPokeSelection==4 and $TrainersPokeSelectionCheck==5
              
            elsif $TrainersPokeSelection==5 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==5 and $TrainersPokeSelectionCheck==5
            elsif $TrainersPokeSelection==5 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==6 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==6 and $TrainersPokeSelectionCheck==4
            elsif $TrainersPokeSelection==6 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==7 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==7 and $TrainersPokeSelectionCheck==4
            elsif $TrainersPokeSelection==7 and $TrainersPokeSelectionCheck==5
              
            elsif $TrainersPokeSelection==8 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==8 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==8 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==9 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==9 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==9 and $TrainersPokeSelectionCheck==5
              
            elsif $TrainersPokeSelection==10 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==10 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==10 and $TrainersPokeSelectionCheck==4
              
            elsif $TrainersPokeSelection==11 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==11 and $TrainersPokeSelectionCheck==5 
            elsif $TrainersPokeSelection==11 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==12 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==12 and $TrainersPokeSelectionCheck==4
            elsif $TrainersPokeSelection==12 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==13 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==13 and $TrainersPokeSelectionCheck==4
            elsif $TrainersPokeSelection==13 and $TrainersPokeSelectionCheck==5
              
            elsif $TrainersPokeSelection==14 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==14 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==14 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==15 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==15 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==15 and $TrainersPokeSelectionCheck==5
              
            elsif $TrainersPokeSelection==16 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==16 and $TrainersPokeSelectionCheck==3
            elsif $TrainersPokeSelection==16 and $TrainersPokeSelectionCheck==4
              
            elsif $TrainersPokeSelection==17 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==17 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==17 and $TrainersPokeSelectionCheck==6
              
            elsif $TrainersPokeSelection==18 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==18 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==18 and $TrainersPokeSelectionCheck==5
              
            elsif $TrainersPokeSelection==19 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==19 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==19 and $TrainersPokeSelectionCheck==4
              
            elsif $TrainersPokeSelection==20 and $TrainersPokeSelectionCheck==1
            elsif $TrainersPokeSelection==20 and $TrainersPokeSelectionCheck==2
            elsif $TrainersPokeSelection==20 and $TrainersPokeSelectionCheck==3
              
            else  
              species=poke[TPSPECIES]
              level=poke[TPLEVEL]
              pokemon=PokeBattle_Pokemon.new(species,level,opponent)
              pokemon.form=poke[TPFORM]
              pokemon.resetMoves
              pokemon.item=poke[TPITEM]
              if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>0
                k=0
                for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
                  pokemon.moves[k]=PBMove.new(poke[move])
                  k+=1
                end
                pokemon.moves.compact!
              end
              pokemon.setAbility(poke[TPABILITY])
              pokemon.setGender(poke[TPGENDER])
              if poke[TPSHINY]   # if this is a shiny Pokémon
                pokemon.makeShiny
              else
                pokemon.makeNotShiny
              end
              pokemon.setNature(poke[TPNATURE])
              iv=poke[TPIV]
              for i in 0...6
                pokemon.iv[i]=iv&0x1F
                pokemon.ev[i]=[85,level*3/2].min
              end
              pokemon.happiness=poke[TPHAPPINESS]
              pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
              if poke[TPSHADOW]   # if this is a Shadow Pokémon
                pokemon.makeShadow rescue nil
                pokemon.pbUpdateShadowMoves(true) rescue nil
                pokemon.makeNotShiny
              end
              pokemon.ballused=poke[TPBALL]
              pokemon.calcStats
              party.push(pokemon)
            end
            $TrainersPokeSelectionCheck+=1
          end
        else
          for poke in trainer[3]
            species=poke[TPSPECIES]
            level=poke[TPLEVEL]
            pokemon=PokeBattle_Pokemon.new(species,level,opponent)
            pokemon.form=poke[TPFORM]
            pokemon.resetMoves
            pokemon.item=poke[TPITEM]
            if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>0
              k=0
              for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
                pokemon.moves[k]=PBMove.new(poke[move])
                k+=1
              end
              pokemon.moves.compact!
            end
            pokemon.setAbility(poke[TPABILITY])
            pokemon.setGender(poke[TPGENDER])
            if poke[TPSHINY]   # if this is a shiny Pokémon
              pokemon.makeShiny
            else
              pokemon.makeNotShiny
            end
            pokemon.setNature(poke[TPNATURE])
            iv=poke[TPIV]
            for i in 0...6
              pokemon.iv[i]=iv&0x1F
              pokemon.ev[i]=[85,level*3/2].min
            end
            pokemon.happiness=poke[TPHAPPINESS]
            pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
            if poke[TPSHADOW]   # if this is a Shadow Pokémon
              pokemon.makeShadow rescue nil
              pokemon.pbUpdateShadowMoves(true) rescue nil
              pokemon.makeNotShiny
            end
            pokemon.ballused=poke[TPBALL]
            pokemon.calcStats
            party.push(pokemon)
          end
        end
    to replace
    Code:
    for poke in trainer[3]
          species=poke[TPSPECIES]
          level=poke[TPLEVEL]
          pokemon=PokeBattle_Pokemon.new(species,level,opponent)
          pokemon.form=poke[TPFORM]
          pokemon.resetMoves
          pokemon.item=poke[TPITEM]
          if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>0
            k=0
            for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
              pokemon.moves[k]=PBMove.new(poke[move])
              k+=1
            end
            pokemon.moves.compact!
          end
          pokemon.setAbility(poke[TPABILITY])
          pokemon.setGender(poke[TPGENDER])
          if poke[TPSHINY]   # if this is a shiny Pokémon
            pokemon.makeShiny
          else
            pokemon.makeNotShiny
          end
          pokemon.setNature(poke[TPNATURE])
          iv=poke[TPIV]
          for i in 0...6
            pokemon.iv[i]=iv&0x1F
            pokemon.ev[i]=[85,level*3/2].min
          end
          pokemon.happiness=poke[TPHAPPINESS]
          pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
          if poke[TPSHADOW]   # if this is a Shadow Pokémon
            pokemon.makeShadow rescue nil
            pokemon.pbUpdateShadowMoves(true) rescue nil
            pokemon.makeNotShiny
          end
          pokemon.ballused=poke[TPBALL]
          pokemon.calcStats
          party.push(pokemon)
        end

    I have this tested and working on Essentials Version 13. I battled the same trainer 4 times and he used a different party of 3 each time :D No errors yet but please let me know any suggestions, problems, questions, concerns, etc!


    **How it Works**

    Spoiler:
     
    Last edited:
    94
    Posts
    11
    Years
    • Seen May 4, 2018
    I got an error, I had to change

    Code:
    if $gameswitches[XXX]==true

    to

    Code:
    if $game_switches[XXX]==true

    Also, I battled the same trainer many times, and sometimes he had only 1 or only 2 pokémon, then eventually I got this error:

    4pGKntH.png


    I battled him using the debug option not an event.
     
    Last edited:

    Rayd12smitty

    Shadow Maker
    645
    Posts
    12
    Years
    • Seen Feb 21, 2016
    I got an error, I had to change

    Code:
    if $gameswitches[XXX]==true

    to

    Code:
    if $game_switches[XXX]==true

    Also, I battled the same trainer many times, and sometimes he had only 1 or only 2 pokémon, then eventually I got this error:

    4pGKntH.png


    I battled him using the debug option not an event.


    My bad with the switch problem. I was using a different method before and didn't change it properly when I copied it over for public use. Does the trainer have 6 pokemon listed in the PBS file entry? If there are less than 6 pokemon to pick from you could be getting an issue where it is picking a slot that doesn't have a pokemon so no pokemon is used. It says in the comments above the script that the trainer must have 6 pokemon. I can change it to support others, but it would be much longer...
     
    94
    Posts
    11
    Years
    • Seen May 4, 2018
    Yeah, I made sure the trainer has 6 pokémon. When the switch is off, all 6 show up in battle.

    I edited Brock

    Code:
    #-------------------
    LEADER_Brock
    Brock
    6
    GEODUDE,12,,DEFENSECURL,HEADSMASH,ROCKPOLISH,ROCKTHROW,0,0,,,,20
    ONIX,14,SITRUSBERRY,HEADSMASH,ROCKTHROW,RAGE,ROCKTOMB,0,0,,true,,20,,Rocky,,19
    SUDOWOODO,11
    RHYHORN,11
    KABUTOPS,11
    OMASTAR,11
    #-------------------
     

    Rayd12smitty

    Shadow Maker
    645
    Posts
    12
    Years
    • Seen Feb 21, 2016
    Yeah, I made sure the trainer has 6 pokémon. When the switch is off, all 6 show up in battle.

    I edited Brock

    Code:
    #-------------------
    LEADER_Brock
    Brock
    6
    GEODUDE,12,,DEFENSECURL,HEADSMASH,ROCKPOLISH,ROCKTHROW,0,0,,,,20
    ONIX,14,SITRUSBERRY,HEADSMASH,ROCKTHROW,RAGE,ROCKTOMB,0,0,,true,,20,,Rocky,,19
    SUDOWOODO,11
    RHYHORN,11
    KABUTOPS,11
    OMASTAR,11
    #-------------------

    Huh:/ I'll do some more testing. I haven't had this issue yet though and I have done multiple battles. It's possible I mad an error in figuring out which selection which pokemon should be part of.

    Alright! After much testing I was able to replicate your issue a few times. I think I am misusing greater than and less than signs. I rewrote the part of the script that determines the different combinations and tested it about 20 times. No issues so far :) Let me know how this one works for you!
     
    Last edited:
    Back
    Top