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

[Scripting Question] Specialized randomizer script?

Chdonga

Pixel Artist/Spriter
  • 24
    Posts
    12
    Years
    I've added this line to PTrainer_NPCTrainers which randomizes their pokemon:
    Code:
    if $game_switches[42]==true # Randomizer On
          randompoke=rand(PBSpecies.maxValue)+1
    
          species=randompoke
    
        else
    
          species=poke[TPSPECIES]
    
        end
    But I need it to be restricted to non-legendaries and only what's in my regional dex. How do I do this without manually inputting 300+ pokemon as an exception?
     
    Last edited by a moderator:
  • 824
    Posts
    9
    Years
    Code:
    def randPokemonInColor(colorW,exceptions=[])
      if colorW.is_a?(String) || colorW.is_a?(Symbol)
        colorW=getID(PBColors,colorW)
      end
      brenda=PBSpecies.maxValue-1
      species=rand(brenda)+1
      bob=PokeBattle_Pokemon.new(species,100,$Trainer)
      dexdata=pbOpenDexData()
      loop do
        pbDexDataOffset(dexdata,bob.species,6)
        colorG=dexdata.fgetb
        break if colorG==colorW
        bob.species=rand(brenda)
      end
      return bob.species
    end
    
    def randSpeciesInType(type,exceptions=[])
      if type.is_a?(String) || type.is_a?(Symbol)
        type=getID(PBColors,type)
      end
      brenda=PBSpecies.maxValue-1
      species=rand(brenda)+1
      bob=PokeBattle_Pokemon.new(species,100,$Trainer)
      loop do
        break if bob.hasType?(type) && !exceptions.include?(bob.species)
        bob.species=rand(brenda)
      end
      return bob.species
    end

    Two functions I use in my own Randomizer scripts. The latter one is used to make Gym Leaders stay within their types, and the former is used for a trainer that only uses Pokemon of a specific color.

    Perhaps they can be adapted to your purpose. You'd have to find a way to check if the generated Pokemon is in your regional dex, though.
     
    Back
    Top