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

Script: [v13+] Pokémon Selection (similar to Stadium/Battle Tower)

Hello! I'm struggling a bit with the script.
I want to make an event where:
-The player can only choose 1 Pokémon
-The Pokémons Height needs to be 6 or less
-Player can cancel the choosing
I was able to do the first two alone, but the issue is if the player doesnt have a mon that fits the criteria theres an error, and I dont seem to understand how to use the ValidTeam? thing.
Can someone show me in an event how I would do this?
Thank you a lot!
 
Hello! I'm struggling a bit with the script.
I want to make an event where:
-The player can only choose 1 Pokémon
-The Pokémons Height needs to be 6 or less
-Player can cancel the choosing
I was able to do the first two alone, but the issue is if the player doesnt have a mon that fits the criteria theres an error, and I dont seem to understand how to use the ValidTeam? thing.
Can someone show me in an event how I would do this?
Thank you a lot!
Since defining PokemonSelection::Parameters is a multiline task, you need to put the param bulding into a method if you want to use it on PokemonSelection.hasValidTeam?. So, add the below method above main:

Code:
def getSingleHeightParam
  ret = PokemonSelection::Parameters.new
  ret.minPokemon = 1
  ret.maxPokemon = 1
  ret.baseChallenge = PokemonChallengeRules.new 
  ret.baseChallenge.addPokemonRule(HeightRestriction.new(6))
  return ret
end

At the event, do this:
Code:
@> Conditional Branch: Script: PokemonSelection.hasValidTeam?(getSingleHeightParam)
 @>PokemonSelection.choose(getSingleHeightParam)
 (Things after selection) 
: Else
 (Things when player has invalid party) 
: Branch End
 
Hello, I'm trying to make my own rules ( the plugin looks like it works with v20) but I have one problem. if I chose ret.minPokemon = 1 and
ret.maxPokemon = 6 in my parameters, the event will reject my entire team if only one pokémon is invalid, instead of allowing me to go to the selection screen to select less than 6 pokémons. If there a way to make it work like intended? Or should I just make a test screen with min and max =1 to let the player know what's wrong?
 
Hello, I'm trying to make my own rules ( the plugin looks like it works with v20) but I have one problem. if I chose ret.minPokemon = 1 and
ret.maxPokemon = 6 in my parameters, the event will reject my entire team if only one pokémon is invalid, instead of allowing me to go to the selection screen to select less than 6 pokémons. If there a way to make it work like intended? Or should I just make a test screen with min and max =1 to let the player know what's wrong?
On an event, do a script conditional branch with 'PokemonSelection.hasValidTeam?' (use the same arguments as PokemonSelection.choose). If you use the PokemonSelection::Parameters, do a method (I explain at the above post).
 
Ok it looks like I wasn't clear enough, sorry. I followed your examples and I don't think the problem comes from here. My rules are something like this

def natdexban(max)
ret = PokemonSelection::Parameters.new
ret.minPokemon = 1
ret.maxPokemon = max
ret.canCancel = true
ret.baseChallenge = PokemonChallengeRules.new
ret.baseChallenge.addTeamRule(SpeciesClause.new)
... (I won't flood the post with a sea of rules)
end

So in my test situation 3 of the 6 pokémons of my team are banned in the rules.
If in my event, I followed your example above.
My problem is simple:

1) If I use max=6, it says invalid team even if I could go there with only 1 pokémon.

2) But if I call it with max=1 everything works correctly (except that obviously I can chose only 1 pkmn).

So my question was: is there a way to have it make me go to the selection screen in the first situation or should I just make a test event with situation 2 to make the player know what's wrong.
 
Ok it looks like I wasn't clear enough, sorry. I followed your examples and I don't think the problem comes from here. My rules are something like this

def natdexban(max)
ret = PokemonSelection::Parameters.new
ret.minPokemon = 1
ret.maxPokemon = max
ret.canCancel = true
ret.baseChallenge = PokemonChallengeRules.new
ret.baseChallenge.addTeamRule(SpeciesClause.new)
... (I won't flood the post with a sea of rules)
end

So in my test situation 3 of the 6 pokémons of my team are banned in the rules.
If in my event, I followed your example above.
My problem is simple:

1) If I use max=6, it says invalid team even if I could go there with only 1 pokémon.

2) But if I call it with max=1 everything works correctly (except that obviously I can chose only 1 pkmn).

So my question was: is there a way to have it make me go to the selection screen in the first situation or should I just make a test event with situation 2 to make the player know what's wrong.
My bad.

I can't reproduce your issue. I tried, with initial Essentials party:

Code:
def getSmallHeightParam
  ret = PokemonSelection::Parameters.new
  ret.minPokemon = 1
  ret.maxPokemon = 6
  ret.baseChallenge = PokemonChallengeRules.new 
  ret.baseChallenge.addPokemonRule(HeightRestriction.new(1))
  return ret
end

And worked as intended (on v19.1, at least).

Can you post a set of rules, so I can reproduce the issue?
 
After some testing it looks like the problem comes from
ret.baseChallenge.addTeamRule(SpeciesClause.new)
ret.baseChallenge.addTeamRule(ItemClause.new)

and ofc I have different items and pokémons in my test team


It looks like it's not even checking anything in my test situation 1 (I added a print in the clause class and nothing comes if max=6 but works normally with max=1, weird)

def bob(max)
ret = PokemonSelection::Parameters.new
ret.minPokemon = 1
ret.maxPokemon = max
ret.canCancel = true
ret.baseChallenge = PokemonChallengeRules.new
ret.baseChallenge.addTeamRule(SpeciesClause.new)
ret.baseChallenge.addTeamRule(ItemClause.new)
ret.baseChallenge.addPokemonRule(BannedSpeciesRestriction.new(:PIKACHU))
return ret
end

I used this for testing
 
Last edited:
After some testing it looks like the problem comes from
ret.baseChallenge.addTeamRule(SpeciesClause.new)
ret.baseChallenge.addTeamRule(ItemClause.new)

and ofc I have different items and pokémons in my test team


It looks like it's not even checking anything in my test situation 1 (I added a print in the clause class and nothing comes if max=6 but works normally with max=1, weird)

def bob(max)
ret = PokemonSelection::Parameters.new
ret.minPokemon = 1
ret.maxPokemon = max
ret.canCancel = true
ret.baseChallenge = PokemonChallengeRules.new
ret.baseChallenge.addTeamRule(SpeciesClause.new)
ret.baseChallenge.addTeamRule(ItemClause.new)
ret.baseChallenge.addPokemonRule(BannedSpeciesRestriction.new(:PIKACHU))
return ret
end

I used this for testing
Looks like an issue when defining both team rules and pokemon rules.

On my script, change 'pbEachCombination(team,teamNumber){|comb|' to 'pbEachCombination(team,self.minLength){|comb|'.

I updated the script.
 
Ofc it works with 20.1

Weird then I will retry again xD

So I don't know if it's because of Pokemon Following

[PokeCommunity.com] [v13+] Pokémon Selection (similar to Stadium/Battle Tower)
 
Last edited:
Weird then I will retry again xD

So I don't know if it's because of Pokemon Following

[PokeCommunity.com] [v13+] Pokémon Selection (similar to Stadium/Battle Tower)
In ruby, you can only break lines in certain parts, like before a dot. So, paste:

Code:
PokemonSelection.choose(
PokemonSelection::Parameters
.new
.setMinPokemon(1)
.setMaxPokemon(1))

Alternatively, run extendtext.ext before opening the text dialog.
 
You need to restore your previous team. call PokemonSelection.restore after the battle
 
Hi, just wanted to report something I found while using this script on Pokémon Essentials v19.1. The selection and party changing related works fine when opening the game the first time, but then if I soft reset using F12, the selection still works, but the party is unchanged from the original party. But then if I close the game and reopen it, the party changing works again.
 
Hi, I would appreciate any help from anyone who see's this...
I am using essentials version 19.1, I have used a ton of Plugins before and made many changes to scripts,
had issues in the past but I have ABSOLUTELY NO CLUE what is going on with yours...
All I did was follow the instructions, I copied your code into the the script editor above the "main",
I tried downloading and putting your script into the plugins folder... I have no idea how to make this script work,
most scripts you just put a folder into plugins, copy some scripts into the editor and maybe add pictures and it works perfectly.
I have been trying for well over 13 hours the last 3 days trying to get this to work and I am dumbfounded and lost.

This is the exact copy of my error text and the ONLY thing I did was add this script in above the "main" section like I normally would and like the directions specified...

=================

[2024-06-19 23:35:16 -0700]
[Pokémon Essentials version 19.1]
[Generation 8 Project v1.1.0]
[v19.1 Hotfixes 1.0.3]

Exception: RuntimeError
Message: Script error in event 3 (coords 6,5), map 10 (Inchoate City Gym):
Exception: NoMethodError
Message: undefined method `register' for #<BattleChallenge>

***Full script:
PokemonSelection.choose(3,3)


Backtrace:
373::257:in `setSimple'
373::165:in `hasValidTeam?'
373::176:in `choose'
(eval):1:in `execute_script'
033:Interpreter:137:in `eval'
033:Interpreter:137:in `execute_script'
034:Interpreter_Commands:1030:in `command_355'
034:Interpreter_Commands:116:in `execute_command'
033:Interpreter:127:in `block in update'
033:Interpreter:87:in `loop'


Backtrace:
033:Interpreter:189:in `rescue in execute_script'
033:Interpreter:135:in `execute_script'
034:Interpreter_Commands:1030:in `command_355'
034:Interpreter_Commands:116:in `execute_command'
033:Interpreter:127:in `block in update'
033:Interpreter:87:in `loop'
033:Interpreter:87:in `update'
032:Scene_Map:157:in `block in update'
032:Scene_Map:155:in `loop'
032:Scene_Map:155:in `update'
 
Back
Top