• 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!
  • 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] [v18] How to set a random 6v6 battle?

  • 125
    Posts
    5
    Years
    • Seen Nov 20, 2023
    Well,I want to set a random 6v6 battle.
    And I use $Trainer.party to random player's pokemon.
    However,I have no idea about the foe's pokemon.
    Could anyone please help me?
     
    You can use encounter modifiers to randomize the foe's Pokemon. The first thing you need to do is create the trainer in trainers.txt and give it 6 dummy Pokemon. They can all be Bulbasaurs or whatever, but it won't matter since they will be randomized at the start of battle. Then make a global switch that you turn on ONLY for this battle, and turn it off as soon as the battle is done. Then you can add the following code to the script section PField_EncounterModifiers:
    Code:
    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
        BAN_LIST = [:SPECIES1, :SPECIES2, ...]
        if $game_switches[XXX]
          for i in 0...party.length
            new_species = rand(PBSpecies.maxValue) + 1
            while BAN_LIST.include?(new_species)
              new_species = rand(PBSpecies.maxValue) + 1
            end
            new_poke = pbNewPkmn(new_species, LEVEL, trainer)
            party[i] = new_poke
          end
        end
      end
    }
    Where XXX is the switch ID that you use, and LEVEL is the level of each of the foe's Pokemon.
     
    Back
    Top