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

Randomized Pokemon Script

AskipLudo

The Masked Guy
159
Posts
7
Years
  • Hello, is there a way that the trainers keep the random pokemon they got?
    Cause when they kill all pokemon from my party and that I go back to them they have different Pokemon.

    Thanks ^^
     
    295
    Posts
    6
    Years
    • Seen Aug 15, 2022
    Hello, is there a way that the trainers keep the random pokemon they got?
    Cause when they kill all pokemon from my party and that I go back to them they have different Pokemon.

    Thanks ^^

    I don't think so! Why you want trainers keep the random? You can set this pokemon for them, just don't use randomized!
     
    308
    Posts
    4
    Years
  • Hello, is there a way that the trainers keep the random pokemon they got?
    Cause when they kill all pokemon from my party and that I go back to them they have different Pokemon.

    Thanks ^^

    This does not work with the way how this randomizer is coded.
    Then you should search for something like a seed generator, that shuffles all species one time at the beginning of the game.
     

    AskipLudo

    The Masked Guy
    159
    Posts
    7
    Years
  • I want to make different options for randomizer

    exemple :

    Everything is random (so switch 36)
    Only wild pokemon (switch xxx)
    Only trainers (switch xxx)
    ect

    How can I do this?
     
    308
    Posts
    4
    Years
  • I want to make different options for randomizer

    exemple :

    Everything is random (so switch 36)
    Only wild pokemon (switch xxx)
    Only trainers (switch xxx)
    ect

    How can I do this?

    If you want to randomize wild pokemon, then use something like this:
    Code:
    Events.onWildPokemonCreate += proc {| sender, e |
      pkmn = e[0]
      if $game_switches[45] # Here 45 is the number of your switch
         pokemon.species = rand(890)+1 # Here 890 is the number of different pokemon species you have in your game
      end
    }
    Read section "Modifying the Pokemon" in https://essentialsdocs.fandom.com/wiki/Event_encounters for more informations.

    If you want to randomize the party of the trainers then try to do the same as above but use
    Code:
    Events.onTrainerPartyLoad
    instead of "Events.onWildPokemonCreate".
    But be careful, you have to randomize the whole party of the trainer not just one pokemon. I can't help you with the details. I hope you find something in the wiki about "Events.onTrainerPartyLoad". Or look for remarks in the PField_Field script section in the script editor concerning "Events.onTrainerPartyLoad".

    And of course, everything is random is either this script, which you can find in the main post, or it is combining the 2 cases above.
     
    295
    Posts
    6
    Years
    • Seen Aug 15, 2022
    Code:
    Events.onWildPokemonCreate += proc {| sender, e |
      pkmn = e[0]
      if $game_switches[45] # Here 45 is the number of your switch
         pokemon.species = rand(890)+1 # Here 890 is the number of different pokemon species you have in your game
      end
    }

    This is wrong code
    You should write something like
    Code:
    Events.onWildPokemonCreate += proc { |_sender, e|
      pokemon = e[0]
      if $game_switches[45]
         pokemon.species = rand(PBSpecies.maxValue)+1
      end
    }
    But with this, if you fight with pokemon which you create on map, it just change sprite.
     
    Last edited:
    295
    Posts
    6
    Years
    • Seen Aug 15, 2022
    I want to make different options for randomizer

    exemple :

    Everything is random (so switch 36)
    Only wild pokemon (switch xxx)
    Only trainers (switch xxx)
    ect

    How can I do this?

    You need to edit the old which I posted here.
    in module Randomized, below
    Code:
      Switch = 1975 # switch ID to randomize a pokemon, if it's on then ALL
                  # pokemon will be randomized. No exceptions.
    Add
    Code:
    SwitchOnlyWild = 1976 # Switch ID
    SwitchOnlyTrainer = 1977 # Switch ID
    Then find def pbWildBattleCore(*args)
    Find elsif arg.is_a?(Array)
    Change
    Code:
    species = getID(PBSpecies,arg[0])
    into
    Code:
          if $game_switches[Randomized::SwitchOnlyWild]
            species = Randomized::WhiteListedPokemon.shuffle
            if Randomized::WhiteListedPokemon.length == 0
              random = 1+rand(PBSpecies.maxValue)
              loop do
                if Randomized.isIDBlack(random)
                  random = 1+rand(PBSpecies.maxValue)
                else
                  break
                end
              end
              species = random
            end
          else
            species = getID(PBSpecies,arg[0])
          end
    Find elsif sp
    Change
    Code:
    species = getID(PBSpecies,sp)
    into
    Code:
          if $game_switches[Randomized::SwitchOnlyWild]
            species = Randomized::WhiteListedPokemon.shuffle
            if Randomized::WhiteListedPokemon.length == 0
              random = 1+rand(PBSpecies.maxValue)
              loop do
                if Randomized.isIDBlack(random)
                  random = 1+rand(PBSpecies.maxValue)
                else
                  break
                end
              end
              species = random
            end
          else
            species = getID(PBSpecies,sp)
          end

    Then find def pbTrainerBattleCore(*args)
    below
    Code:
    scene = pbNewBattleScene
    add
    Code:
      if $game_switches[Randomized::SwitchOnlyTrainer]
        (0...foeParty.size).each{ |i|
        old = foeParty[i].level
        species = Randomized::WhiteListedPokemon.shuffle
        if Randomized::WhiteListedPokemon.length == 0
          random = 1+rand(PBSpecies.maxValue)
          loop do
            if Randomized.isIDBlack(random)
              random = 1+rand(PBSpecies.maxValue)
            else
              break
            end
          end
          foeParty[i].species = random
          foeParty[i].level = old
          foeParty[i].calcStats
          foeParty[i].resetMoves
        else
          foeParty[i].species = species
          foeParty[i].level = old
          foeParty[i].calcStats
          foeParty[i].resetMoves
        end }
      end
     
    295
    Posts
    6
    Years
    • Seen Aug 15, 2022
    And there is a way to only randomize trainers 1 time to not find new pokemon on gyms/trainers?

    Add it above Main
    Code:
    class PokemonGlobalMetadata
      attr_accessor :storeRandomPkmn
      attr_accessor :wantStoreRandomPkmn
      
      alias random_ini initialize
      def initialize
        @wantStoreRandomPkmn = false
        # Old
        random_ini
      end
    end
    
    def setRandomStore(name,pokemon)
      $PokemonGlobal.storeRandomPkmn={} if !$PokemonGlobal.storeRandomPkmn
      $PokemonGlobal.storeRandomPkmn[name]={} if !$PokemonGlobal.storeRandomPkmn[name]
      $PokemonGlobal.storeRandomPkmn[name][pokemon]={} if !$PokemonGlobal.storeRandomPkmn[name][pokemon]
    end

    If you want to store pokemon of trainer, set it before start battle
    Code:
    $PokemonGlobal.wantStoreRandomPkmn = true
    If not, set
    Code:
    $PokemonGlobal.wantStoreRandomPkmn = false

    find def pbTrainerBattleCore(*args)
    You change all the code I posted here and you added it in this def. Change it into
    Code:
      if $game_switches[Randomized::Switch]
        nametrainerevent="#{pbMapInterpreter.get_character(0).id} #{$game_map.map_id}"
        (0...foeParty.size).each{ |i|
        old = foeParty[i].level
        species = Randomized::WhiteListedPokemon.shuffle
        if Randomized::WhiteListedPokemon.length == 0
          random = 1+rand(PBSpecies.maxValue)
          loop do
            if Randomized.isIDBlack(random)
              random = 1+rand(PBSpecies.maxValue)
            else
              break
            end
          end
          foeParty[i].species = random
          foeParty[i].level = old
          foeParty[i].calcStats
          foeParty[i].resetMoves
        else
          foeParty[i].species = species
          foeParty[i].level = old
          foeParty[i].calcStats
          foeParty[i].resetMoves
        end
        # Set
        setRandomStore(nametrainerevent,"#{i}")
        t = $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]
        if t.length<2
          if $PokemonGlobal.wantStoreRandomPkmn
            $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["species"] = foeParty[i].species
            $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["level"] = foeParty[i].level
          end
        else
          foeParty[i].species = $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["species"]
          foeParty[i].level = $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["level"]
          foeParty[i].calcStats
          foeParty[i].resetMoves
        end }
      end
     
    Last edited:
    295
    Posts
    6
    Years
    • Seen Aug 15, 2022
    I want to make different options for randomizer

    exemple :

    Everything is random (so switch 36)
    Only wild pokemon (switch xxx)
    Only trainers (switch xxx)
    ect

    How can I do this?

    Do you still want it? You need to change some lines.
    Check in module Randomized, add if you don't see it in your change.
    Code:
    module Randomized
      Switch = 1975 # switch ID to randomize a pokemon, if it's on then ALL
                  # pokemon will be randomized. No exceptions.
      SwitchOnlyWild = 1976 # Switch ID
      SwitchOnlyTrainer = 1977 # Switch ID
    
      BlackListedPokemon = [:MEW,: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.
      
      def self.isIDBlack(id)
        (0...BlackListedPokemon.size).each{|i|
        if getID(PBSpecies,BlackListedPokemon[i])==id
          return true
          break
        end }
        return false
      end
      
      def self.random
        ret = WhiteListedPokemon.shuffle
        if WhiteListedPokemon.length == 0
          ret = 1+rand(PBSpecies.maxValue)
          loop do
            if self.isIDBlack(ret)
              ret = 1+rand(PBSpecies.maxValue)
            else
              break
            end
          end
        end
        ret = getID(PBSpecies,ret)
        return ret
      end
      
    end

    Delete all the change in class PokeBattle_Pokemon, in def initialize(species,level,player=nil,withMoves=true) and in def pbWildBattleCore(*args) and in def pbTrainerBattleCore(*args), change all like the old (raw of PE).

    After do that, add this above Main, you can put it same place of module Randomized, above or below it.
    Code:
    Events.onWildPokemonCreate += proc { |_sender, e|
      pokemon = e[0]
      oldlevel = pokemon.level
      if $game_switches[Randomized::Switch] || $game_switches[Randomized::SwitchOnlyWild]
        pokemon.species = Randomized.random
        pokemon.level = oldlevel
        pokemon.calcStats
        pokemon.resetMoves
      end
    }
    
    Events.onTrainerPartyLoad += proc { |_sender, e|
      if e[0]
        trainer = e[0][0] 
        items = e[0][1]   
        party = e[0][2]
        if $game_switches[Randomized::Switch] || $game_switches[Randomized::SwitchOnlyTrainer]
          nametrainerevent="#{pbMapInterpreter.get_character(0).id} #{$game_map.map_id}"
          (0...party.size).each{|i|
          oldlevel=party[i].level
          party[i].species=Randomized.random
          party[i].level=oldlevel
          party[i].calcStats
          party[i].resetMoves 
          # Set
          setRandomStore(nametrainerevent,"#{i}")
          t = $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]
          if t.length<2
            if $PokemonGlobal.wantStoreRandomPkmn
              $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["species"] = party[i].species
              $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["level"] = party[i].level
            end
          else
            party[i].species = $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["species"]
            party[i].level = $PokemonGlobal.storeRandomPkmn[nametrainerevent]["#{i}"]["level"]
            party[i].calcStats
            party[i].resetMoves
          end }
        end
      end
    }

    And you need to keep it
    Code:
    class PokemonGlobalMetadata
      attr_accessor :storeRandomPkmn
      attr_accessor :wantStoreRandomPkmn
      
      alias random_ini initialize
      def initialize
        @wantStoreRandomPkmn = false
        # Old
        random_ini
      end
    end
    
    def setRandomStore(name,pokemon)
      $PokemonGlobal.storeRandomPkmn={} if !$PokemonGlobal.storeRandomPkmn
      $PokemonGlobal.storeRandomPkmn[name]={} if !$PokemonGlobal.storeRandomPkmn[name]
      $PokemonGlobal.storeRandomPkmn[name][pokemon]={} if !$PokemonGlobal.storeRandomPkmn[name][pokemon]
    end

    Set $PokemonGlobal.wantStoreRandomPkmn like my old post
     
    Last edited:

    AskipLudo

    The Masked Guy
    159
    Posts
    7
    Years
  • HEy thats me again, so I noticed that during double trainer battle the two trainer had the same randomized pokemon, is that normal?
     
    Back
    Top