Rayd12smitty
Shadow Maker
- 645
- Posts
- 13
- 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
to replace
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**
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
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:
So many people here use public scripts just copying and pasting them and then take it for granted. I'm just going to share a bit of how this script works so if you want, you can understand what you just changed in your game. I feel if everyone just picks up a little new information it can build up to them actually learning something about scripting. This is how I learned and how I continue to learn. You need to learn little things at a time, and then work at putting together to do something new!
So, the part of the script that we replaced is pretty much just checking the PBS file for trainers to get all of the information for however many pokemon they have. First of all, I added an "if statement" to check if the game should load the data like a normal trainer, or if switch[XXX] is true, load the data for a special 3 pokemon select trainer.
Then the script sets 2 variables. The first is set to a random number between 0 and 19, and then it adds 1 to it so we really get a number between 1 and 20. When there are 6 pokemon, and we need a combination of 3, there are 20 possible combinations. This variable determines which one will be used. The second variable is just saying that the script should check pokemon number 1 first.
Next comes the original script with a few edits. When it says "for poke in trainer[3]" it will run the indented part of the script for every pokemon that comes up in the trainer's PBS file entry. The lines followed by comments are where I figured out if the pokemon should be included or not. I figured out what each of the 20 combinations of 3 would look like, and if the script finds that the pokemon is not part of the randomly selected combination, the pokemon's data is not added to the trainer for the battle, and it moves on to the next pokemon.
The only other change I made is after adding all the pokemon's data, it increases the current pokemon it is checking by one, so the script checks the 2nd pokemon next, and then the 3rd, and so on.
The rest of the script is what happens in the original switch[XXX] is not on. The script will just run like normal.
So, the part of the script that we replaced is pretty much just checking the PBS file for trainers to get all of the information for however many pokemon they have. First of all, I added an "if statement" to check if the game should load the data like a normal trainer, or if switch[XXX] is true, load the data for a special 3 pokemon select trainer.
Then the script sets 2 variables. The first is set to a random number between 0 and 19, and then it adds 1 to it so we really get a number between 1 and 20. When there are 6 pokemon, and we need a combination of 3, there are 20 possible combinations. This variable determines which one will be used. The second variable is just saying that the script should check pokemon number 1 first.
Next comes the original script with a few edits. When it says "for poke in trainer[3]" it will run the indented part of the script for every pokemon that comes up in the trainer's PBS file entry. The lines followed by comments are where I figured out if the pokemon should be included or not. I figured out what each of the 20 combinations of 3 would look like, and if the script finds that the pokemon is not part of the randomly selected combination, the pokemon's data is not added to the trainer for the battle, and it moves on to the next pokemon.
The only other change I made is after adding all the pokemon's data, it increases the current pokemon it is checking by one, so the script checks the 2nd pokemon next, and then the 3rd, and so on.
The rest of the script is what happens in the original switch[XXX] is not on. The script will just run like normal.
Last edited: