• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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
    13
    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:
    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.
     
    • Like
    Reactions: Mab
    What would I use to check if the mon's from the regional dex?
     
    Back
    Top