• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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.

Random Pokemon Based on vsTrainer

Zeak6464

Zeak #3205 - Discord
  • 1,101
    Posts
    12
    Years
    This code will allows the player to Randomize Opponent Trainer Pokemon based on TrainerType

    This script is plug&play !

    Credit goes to :
    Zeak6464
    Vendily
    Umbra

    Code:
    EVIL_TEAM_LIST = [
      :TEAMROCKET_Male,
      :TEAMROCKET_Female,
      :TEAMROCKET_f,
      :TEAMROCKET_m,
      :TEAMROCKET_JJ
    ]
    
      def generatePokemon(level)
        species = rand(PBSpecies.maxValue) + 1
        species = pbGetBabySpecies(species) # revert to the first evolution
        item = 0
        loop do
          nl = level + 5
          nl = MAXIMUMLEVEL if nl > MAXIMUMLEVEL
          pkmn = PokeBattle_Pokemon.new(species, nl)
          cevo = Kernel.pbCheckEvolution(pkmn)
          evo = pbGetEvolvedFormData(species)
          if evo
            evo = evo[rand(evo.length - 1)]
            # evolve the species if we can't evolve and there is an evolution
            # and a bit of randomness passes as well as the evolution type cannot
            # be by level
            if evo && cevo < 1 && rand(MAXIMUMLEVEL) <= level
              species = evo[2] if evo[0] != 4 && rand(MAXIMUMLEVEL) <= level
            end
          end
          if cevo == -1 || (rand(MAXIMUMLEVEL) > level && level < 60)
            # ^ Only break the loop if there is no more evolutions or some randomness
            # applies and the level is under 60 
            break
          else
            species = evo[2]
          end
        end
         return species
    end
    
    Events.onTrainerPartyLoad+=proc {|sender,e|
       if e[0] # Trainer data should exist to be loaded, but may not exist somehow
         trainer=e[0][0] # A PokeBattle_Trainer object of the loaded trainer
         items=e[0][1]   # An array of the trainer's items they can use
         party=e[0][2]   # An array of the trainer's Pok?mon
         ids=EVIL_TEAM_LIST
         balance=false
         ids.each{|item|
            balance|=isConst?(trainer.trainertype,PBTrainers,item)
         }
         if balance
           party.each{|poke|
             level=pbBalancedLevel($Trainer.party)- 4
             poke.species=generatePokemon(level)
             poke.level=level
             poke.name=PBSpecies.getName(poke.species)
             poke.calcStats
             poke.resetMoves
           }
         end
       end
    }
     
    Last edited:
    Back
    Top