• 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?".
  • Forum moderator applications are now open! Click here for details.
  • 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.

Randomized Pokemon Script

1,748
Posts
14
Years
Just as the title states, it randomizes any and all pokemon you encounter. Whether it's a gift, a wild pokemon, or a trainer battle it'll all be random.

Although, you must activate a switch (see the comments on how to edit the switch number) for it to become active.

Code:
################################################################################
# Randomized Pokemon Script
# By Umbreon
################################################################################
# Used for a randomized pokemon challenge mainly.
# 
# By randomized, I mean EVERY pokemon will be random, even interacted pokemon
#   like legendaries. (You may easily disable the randomizer for certain
#    situations like legendary battles and starter selecting.)
#
# To use: simply activate Switch Number X
#  (X = the number listed After "Switch = ", default is switch number 36.)
#
# If you want certain pokemon to NEVER appear, add them inside the black list.
#  (This does not take into effect if the switch stated above is off.)
#
# If you want ONLY certain pokemon to appear, add them to the whitelist. This
#   is only recommended when the amount of random pokemon available is around
#   32 or less.(This does not take into effect if the switch stated above is off.)
#
################################################################################

########################## You may edit any settings below this freely.
module RandomizedChallenge
  Switch = 36 # switch ID to randomize a pokemon, if it's on then ALL
              # pokemon will be randomized. No exceptions.
                        
  BlackListedPokemon = [PBSpecies::MEW, PBSpecies::ARCEUS]
  # Pokemon to Black List. Any pokemon in here will NEVER appear.
  
  WhiteListedPokemon = []
  # Leave this empty if all pokemon are allowed, otherwise only pokemon listed
  # above will be selected.
end

######################### Do not edit anything below here.
class PokeBattle_Pokemon
  
  alias randomized_init initialize
  
  def initialize(species,level,player=nil,withMoves=true)

    species = RandomizedChallenge::WhiteListedPokemon.shuffle[0]
    
    if $game_switches && $game_switches[RandomizedChallenge::Switch]
      if RandomizedChallenge::WhiteListedPokemon.length == 0
        species = rand(PBSpecies.maxValue - 1) + 1
        while RandomizedChallenge::BlackListedPokemon.include?(species)
          species = rand(PBSpecies.maxValue - 1) + 1
        end
      end
    end
    
    randomized_init(species, level, player, withMoves)
  end
end
 
Last edited:
15
Posts
10
Years
  • Age 23
  • Seen Jan 10, 2017
This is amazing and works perfectly. Thanks! How would you like me to credit you?
 
57
Posts
10
Years
  • Age 31
  • Seen Sep 10, 2022
Wow I've seen only now this great code, you just made my day!! =)
 

Schrroms

Pokémon Infinite Fusion dev
334
Posts
8
Years
Awesome, this is exactly what I needed for my game!
Thanks, I'll credit you of course!
 
11
Posts
8
Years
  • Age 33
  • Seen Jun 4, 2016
Can you help me is a simpe dude if i wanted this to be activate by a option in the intro how could i do it so it activates when you select randomized and desactivate when you pick a nuzlocke or history sorry for borhering also great job with this scripts
 
1,748
Posts
14
Years
Can you help me is a simpe dude if i wanted this to be activate by a option in the intro how could i do it so it activates when you select randomized and desactivate when you pick a nuzlocke or history sorry for borhering also great job with this scripts

There is a line that looks like this in the script:

Code:
Switch = 36 # switch ID to randomize a pokemon, if it's on then ALL

Change "36" to the switch ID of what switch you want for this script to be activated.

Now in the intro say something like "Enable Random Pokemon? [Yes/No]"

Under Yes enable the switch mentioned above.
 
230
Posts
17
Years
  • Seen Oct 18, 2023
Hi Umbreon,

I activated the switch, but now, no Pokemon appear at all. I'm not sure what I did wrong...
 

ReVaN777

Creator of Pokemon Titanium
108
Posts
12
Years
Hey Umbreon

Quick question: is there a way to make this script just change wild encounter and not all Pokemon encounter such as gifts and trainer stay the same. But wilds are random.
 
1,748
Posts
14
Years
Hi Umbreon,

I activated the switch, but now, no Pokemon appear at all. I'm not sure what I did wrong...

Sorry for the late reply, but it should be fixed now.

Hey Umbreon

Quick question: is there a way to make this script just change wild encounter and not all Pokemon encounter such as gifts and trainer stay the same. But wilds are random.

^ See above, temporarily disable the switch and then re-enable.
 

Helric

Legendary Batcher
6
Posts
8
Years
  • Age 46
  • Seen Oct 22, 2016
Sorry for the necropost, but I'm getting this error:


eba8e5cc8d2d3966822470abe69104b3o.png
 
8
Posts
7
Years
  • Age 37
  • Seen Jun 25, 2018
¡Hello! I got an error trying to use the Script, it is only WHEN SWITCH IS OFF.
when its On all random pokemon and trainer works well! but i need to turn it off sometimes to give a starter pokemon or legendaries, ¿Can anyone helps me? its so much important to me...

CODE ERROR-----------------------------------------------------

---------------------------
Pokemon Essentials
---------------------------
Exception: ArgumentError

Message: The species number (no. of 721) is invalid.

PokeBattle_Pokemon:891:in `__mf_initialize'

Pokemon_MultipleForms:133:in `randomized_init'

Randomlocke:54:in `initialize'

PField_Field:833:in `new'

PField_Field:833:in `pbGenerateWildPokemon'

PField_Field:895:in `pbWildBattle'

PField_Field:1374:in `pbBattleOnStepTaken'

PField_Field:1398:in `pbOnStepTaken'

Game_Player:484:in `update_old'

Walk_Run:76:in `follow_update'



This exception was logged in

C:\Users\Victor\Saved Games/Pokemon Essentials/errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
Aceptar
---------------------------
 
33
Posts
7
Years
¡Hello! I got an error trying to use the Script, it is only WHEN SWITCH IS OFF.
when its On all random pokemon and trainer works well! but i need to turn it off sometimes to give a starter pokemon or legendaries, ¿Can anyone helps me? its so much important to me...

CODE ERROR-----------------------------------------------------

---------------------------
Pokemon Essentials
---------------------------
Exception: ArgumentError

Message: The species number (no. of 721) is invalid.

PokeBattle_Pokemon:891:in `__mf_initialize'

Pokemon_MultipleForms:133:in `randomized_init'

Randomlocke:54:in `initialize'

PField_Field:833:in `new'

PField_Field:833:in `pbGenerateWildPokemon'

PField_Field:895:in `pbWildBattle'

PField_Field:1374:in `pbBattleOnStepTaken'

PField_Field:1398:in `pbOnStepTaken'

Game_Player:484:in `update_old'

Walk_Run:76:in `follow_update'



This exception was logged in

C:\Users\Victor\Saved Games/Pokemon Essentials/errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
Aceptar
---------------------------
Yupp the exact same thing happened to me
 
1,669
Posts
8
Years
  • Age 23
  • Seen yesterday
Just as the title states, it randomizes any and all pokemon you encounter. Whether it's a gift, a wild pokemon, or a trainer battle it'll all be random.

Although, you must activate a switch (see the comments on how to edit the switch number) for it to become active.

Umbra, your code is slightly broken. It gives an error when it's off if there are no whitelisted Pokemon, because it changes the species to nil first.

Code:
class PokeBattle_Pokemon
  
  alias randomized_init initialize
  
  def initialize(species,level,player=nil,withMoves=true)
    
    if $game_switches && $game_switches[RandomizedChallenge::Switch]
      [COLOR="Red"]species = RandomizedChallenge::WhiteListedPokemon.shuffle[0][/COLOR]
      if RandomizedChallenge::WhiteListedPokemon.length == 0
        species = rand(PBSpecies.maxValue - 1) + 1
        while RandomizedChallenge::BlackListedPokemon.include?(species)
          species = rand(PBSpecies.maxValue - 1) + 1
        end
      end
    end
    
    randomized_init(species, level, player, withMoves)
  end
end

This fixes the error. I don't need credit. Please update the first post though.
 
5
Posts
13
Years
  • Seen Sep 3, 2020
Out of curiosity and desire to create a more customizable experience for players, is there any way to separate the randomization of Trainers' Pokemon and Wild Pokemon into two different switches? How complicated would it be to create something like that?
 

Zeak6464

Zeak #3205 - Discord
1,101
Posts
10
Years
  • Age 31
  • USA
  • Seen Oct 9, 2023
Out of curiosity and desire to create a more customizable experience for players, is there any way to separate the randomization of Trainers' Pokemon and Wild Pokemon into two different switches? How complicated would it be to create something like that?

yes there is a way

Code:
################################################################################
# Pokemon Level Balancing / Pokemon Randomizer 
# By Umbreon
################################################################################
# Balances any and all pokemon's levels towards the player's party level.
#
# NOTE: This won't affect any pokemon the player owns.
#
# To use: simply activate Switch Number X
#  (X = the number listed After "Switch = ", default is switch number 37.)
#
#
################################################################################


module LevelBalance
  Switch = 37 # The switch used to activate/deactivate the level balancing
end

module Random
  Switch = 36 # The switch used to activate/deactivate the level balancing
end

class PokeBattle_Pokemon
  
  alias balanced_level_init initialize
  
  def initialize(species,level,player=nil,withMoves=true)
    
    if $game_switches && $game_switches[LevelBalance::Switch] && $Trainer && $Trainer.party.length > 0
      level = pbBalancedLevel($Trainer.party)
    end
    
    if  $game_switches &&  $game_switches[Random::Switch]
      level = pbBalancedLevel($Trainer.party)
      species = rand(PBSpecies.maxValue)- 1
    end
    
      if $game_switches &&  PBTrainers::TEAMROCKET_M  && $game_switches[Random::Switch]
      level = pbBalancedLevel($Trainer.party)
      species = rand(PBSpecies.maxValue)- 1
    end
    
      if $game_switches && PBTrainers::TEAMROCKET_F  && $game_switches[Random::Switch]
      level = pbBalancedLevel($Trainer.party)
      species = rand(PBSpecies.maxValue)- 1
    end
    
    balanced_level_init(species, level, player, withMoves)
  end
end
 
Back
Top