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

Simple Pokémon World Tournament system

Derxwna Kapsyla

Derxwna "The Badman" Kapsyla
437
Posts
12
Years
The dropbox link for the resources is broken. Does anybody have a second link or reupload?

Can you please update the Resource Pack? It's offline.

I can't find the pack with the resources anywhere on my machine. So I'll have to make a new one.

I have begun work on a completely new version of this system, which is going to be a lot better than the current version. I'm just a tad caught up with other things, so I'm not frequently working on it. The next time I update this thread, it'll be with the new version being posted. That'll come with new resources, among other things.

So, I went through my downloads folder to clean it out, and I believe I found an unedited version of the Resources pack. I uploaded it to mega if anyone needs it. It should go without saying that the kit belongs to Luka, and if he wants me to pull it down so he can re-up it to his server I'll do that at his request.
 
23
Posts
8
Years
  • Age 30
  • Seen Nov 24, 2016
luka very good job, is amazing! i need only one hint please, i want made two tournament, one eith cap 50 and one with 100. how can i do this? someone can help me please?
 

thepsynergist

Vinemon: Sauce Edition Programmer and Composer
795
Posts
15
Years
Hey, Luka, it's been a while. I tried to PM this to you, but you disabled PM's, so I figured I'd just respond in the thread.

First things first, I've resumed work on Pokemon Pyrite, and I'm almost done with it. All I have to do is the end game, and I can release it. I was planning on using your World Tournament script to make a "Pokemon League" of sorts, similar to the Pokemon anime. However, because I haven't upgraded Pokemon Essentials since I started working on my project (April 2010 build), there are bound to be some syntax errors in migrating the script.

So, let me cut to the chase here. If you can, I'd love for some help trying to get the code working on this version of essentials. Unfortunately, I've edited this script so much over the years, that upgrading to the latest version of Essentials would most likely break more than 1/2 of my game.

At the moment, I've got a syntax error that references the variable, "choosePokemon" on line 186 of the posted script.
Spoiler:

If you could help me out, I'd be really thankful.
 

Zeak6464

Zeak #3205 - Discord
1,101
Posts
11
Years
  • Age 31
  • USA
  • Seen Oct 9, 2023
PWT on 16.2



Code:
#===============================================================================
# Pokemon World Tournament script created by Luka S.J.
# Please give credit when used
#===============================================================================
# Place the script above Main and you're ready to go. This script aims to 
# provide a full PWT experience for Essentials (minus the nice visual part).
# I've even gone a little further, and added some things not present in the
# official PWT.
# Call it in a script/even script as PokemonWorldTournament.new
#
#===============================================================================
# Settings
#===============================================================================
# Here you can configure the various aspects of the system.
# Trainers should be defined through the editor, or the PBS file, but should be
# linked/called here just the same way you would in a normal trainer event
#
# This is a list of the types of battles available
# Make sure that World Leaders is in the list after all the other Gym Leader
# Tournament branches.
  BATTLE_LIST = [
                  "Kanto Leaders",
                  "Johto Leaders",
                  "Hoenn Leaders",
                  "Sinnoh Leaders",
                  "Unova Leaders",
                  "World Leaders",
                  "World Champions",
                  "Rental Masters", # not yet implemented
                  "Mix Master" # not yet implemented
                ]
# This is a list of the Pokemon that cannot be used in the PWT                
  BAN_LIST = [
              PBSpecies::MEWTWO,
              PBSpecies::MEW,
              PBSpecies::HOOH,
              PBSpecies::LUGIA,
              PBSpecies::CELEBI,
              PBSpecies::KYOGRE,
              PBSpecies::GROUDON,
              PBSpecies::RAYQUAZA,
              PBSpecies::DEOXYS,
              PBSpecies::JIRACHI,
              PBSpecies::DIALGA,
              PBSpecies::PALKIA,
              PBSpecies::GIRATINA,
              PBSpecies::HEATRAN,
              PBSpecies::DARKRAI,
              PBSpecies::SHAYMIN,
              PBSpecies::ARCEUS,
              PBSpecies::ZEKROM,
              PBSpecies::RESHIRAM,
              PBSpecies::KYUREM,
              PBSpecies::LANDORUS,
              PBSpecies::MELOETTA,
              PBSpecies::KELDEO,
              PBSpecies::GENESECT
            ]
                  
# This is the list of all the defined trainers
# Trainers are defined as arrays containing:
# [ trainer type , trainer name , player victory speech , player loss speech , region they are from , City/Town they are from , Sprite image name (this can be left blank, and the sprite will be used as Leader_Name) ]
#
# The index of the trainer list has to correspond with the category type.
# If you're creating your own trainer list, make sure it has at least 8 entries, otherwise it won't work.
  TRAINER_LIST = [
                  #-------------------------------------------------------------
                  [
                  # List of all the trainers for the Kanto Leaders Tournament
                    [PBTrainers::LEADER_0,"Brock","Looks like you were the sturdier of us.","My barrier was tough to break. Maybe next time.","Kanto","Pewter City"],
                    [PBTrainers::LEADER_1,"Misty","You are a skilled Trainer, I have to admit that.","Looks like out of the two of us, I was the better Trainer.","Kanto","Cerulean City"],
                    [PBTrainers::LEADER_2,"Lt.Surge","You shocked my very core, soldier!","At ease son, not everyone can beat me.","Kanto","Vermillion City"],
                    [PBTrainers::LEADER_3,"Erika","Oh my! \n Looks like I've underestimated you.","Keep practicing hard, and one day you will be the victor.","Kanto","Celadon City"],
                    [PBTrainers::LEADER_4,"Sabrina","Impossible! I did not predict this!","The outcome was just as I predicted.","Kanto","Saffron City"],
                    [PBTrainers::LEADER_5,"Janine","You've got a great battle technique!","My technique was the superior one!","Kanto","Fuchsia City"],
                    [PBTrainers::LEADER_6,"Blaine","Your flame burnt me up!","My flames are not something everyone can handle.","Kanto","Cinnabar Island"],
                    [PBTrainers::LEADER_7,"Giovanni","What? \nMe, lose?!","I could have never lost to a kid like you!","Kanto","Viridian City"]
                  ],
                  #-------------------------------------------------------------
                  #-------------------------------------------------------------
                  [
                  # List of all the trainers for the Johto Leaders Tournament
                    [PBTrainers::LEADER_8,"Falkner","I understand... I'll bow out gracefully.","My birds and I will always fly!","Johto","Violet City"],
                    [PBTrainers::LEADER_9,"Bugsy","Aw, that's the end of it...","My tough Bug Pokemon cannot be defeated easily.","Johto","Azlea Town"],
                    [PBTrainers::LEADER_10,"Whitney","Ugh...","You really are strong! But I won't lose to you!","Johto","Goldenrod City"],
                    [PBTrainers::LEADER_11,"Morty","How is this possible...","We've got more discipline than anyone else!","Johto","Ecruteak City"],
                    [PBTrainers::LEADER_12,"Chuck","We...lost...","No... Not...yet...","Johto","Cianwood City"],
                    [PBTrainers::LEADER_13,"Jasmine","Well done...","Steel will hang on to the very last!","Johto","Olivine City"],
                    [PBTrainers::LEADER_14,"Pryce","Hmm. Seems as if my luck has run out.","My luck has not run out just yet.","Johto","Mahogany Town"],
                    [PBTrainers::LEADER_15,"Clair","I lost... I don't believe it. There must be some mistake...","I was destined to win! I had already decided that!","Johto","Blackthorn City"]
                  ],
                  #-------------------------------------------------------------
                  #-------------------------------------------------------------
                  [
                  # List of all the trainers for the Hoenn Leaders Tournament
                    [PBTrainers::LEADER_16,"Roxanne","So... I lost...","I learned many things from our battle.","Hoenn","Rustboro City"],
                    [PBTrainers::LEADER_17,"Brawly","Whoa, wow! You made a much bigger splash than I expected!","All right! I rode the big wave!","Hoenn","Dewford Town"],
                    [PBTrainers::LEADER_18,"Wattson","Wahahahah! Fine, I lost! You ended up giving me a thrill!","Wahahahah! Well, I won! How was the battle? Thrilling, right?","Hoenn","Mauville City"],
                    [PBTrainers::LEADER_19,"Flannery","Oh... I guess I was trying too hard...","I... I won! I guess my well-honed moves worked!","Hoenn","Lavaridge Town"],
                    [PBTrainers::LEADER_20,"Norman","... I... I can't... I can't believe it. I lost to you?","We both gave everything we had. That was a wonderful match.","Hoenn","Petalburg City"],
                    [PBTrainers::LEADER_21,"Winona","A Trainer that commands Pokémon with more grace than I...","Our elegant dance is finished!","Hoenn","Fortree City"],
                    [PBTrainers::LEADER_22,"Tate&Liza","Oh! The combination of me and my Pokémon...","The combination of me and my Pokémon was superior!","Hoenn","Mossdeep City"],
                    [PBTrainers::LEADER_24,"Juan","Ahahaha, excellent! Very well, you are the winner.","Ahahaha, I'm the winner! Which is to say, you lost.","Hoenn","Sootopolis City"]
                  ],
                  #-------------------------------------------------------------
                  #-------------------------------------------------------------
                  [
                  # List of all the trainers for the Sinnoh Leaders Tournament
                    [PBTrainers::LEADER_25,"Roark","W-what? That can't be! My buffed-up Pokémon!","No way I would have lost to you!","Sinnoh","Oreburgh City"],
                    [PBTrainers::LEADER_26,"Gardenia","Amazing! You're very good, aren't you?","You did not have me concerned at all.","Sinnoh","Eterna City"],
                    [PBTrainers::LEADER_27,"Fantina","You are so fantastically strong. I know now why I have lost.","Never give up, never surrender!","Sinnoh","Hearthome City"],
                    [PBTrainers::LEADER_28,"Mayleene","I shall admit defeat... You are much too strong.","I take battling very seriously.","Sinnoh","Veilstone City"],
                    [PBTrainers::LEADER_29,"Wake","Hunwah! It's gone and ended! How will I say... I want more! I wanted to battle a lot more!","I had a great time battling with you!","Sinnoh","Solaceon"],
                    [PBTrainers::LEADER_30,"Byron","Hmm! My sturdy Pokémon, defeated!","Though you may lost today, the road of a great Trainer still lies ahead of you.","Sinnoh","Canalave City"],
                    [PBTrainers::LEADER_31,"Candice","I must say, I've warmed up to you! I might even admire you a little.","I'm tough because I know how to focus. It's all about focus!","Sinnoh","Snowpoint City"],
                    [PBTrainers::LEADER_32,"Volkner","You've got me beat... Your desire and the noble way your Pokémon battled for you... I even felt thrilled during our match. That was a very good battle.","You guys are tough! But we surpass your toughness!","Sinnoh","Sunyshore City"]
                  ],
                  #-------------------------------------------------------------
                  #-------------------------------------------------------------
                  [
                  # List of all the trainers for the Unova Leaders Tournament
                    [PBTrainers::LEADER_33,"Cheren","This! This is what a real Pokémon battle is!","You were a powerful opponent, there is no denying that.","Unova","Aspertia City"],
                    [PBTrainers::LEADER_34,"Roxie","Wait! I was right in the middle of the chorus!","Looks like I knocked some sense outta ya!","Unova","Virbank City"],
                    [PBTrainers::LEADER_35,"Burgh","Is it over? Has my muse abandoned me?"," bug Pokémon are scurrying with excitement of battling!","Unova","Castelia City"],
                    [PBTrainers::LEADER_36,"Elesa","I meant to make your head spin, but you shocked me instead.","My Pokemon shined brilliantly!","Unova","Nimbasa City"],
                    [PBTrainers::LEADER_37,"Clay","Well, I've had enough... and just so you know, I didn't go easy on you.","Sorry, I didn't go easy on you.","Unova","Driftveil City"],
                    [PBTrainers::LEADER_38,"Skyla","Being your opponent in battle is a new source of strength to me. Thank you!","Next time, why don't you try something else?","Unova","Mistralton City"],
                    [PBTrainers::LEADER_39,"Drayden","This intense feeling that floods me after a defeat... I don't know how to describe it.","I'm grateful we had a chance to meet and battle.","Unova","Opelucid City"],
                    [PBTrainers::LEADER_40,"Marlon","You totally rocked that! You're raising some wicked Pokémon. You got this Trainer thing down!","Fightin' you felt real good, so I kept goin' and goin'.","Unova","Humilau City"]
                  ],
                  #-------------------------------------------------------------
                  # Generates the list for the World Leaders Tournament
                  [ "slot reserved for World Leaders Tournament" ],
                  #-------------------------------------------------------------
                  #-------------------------------------------------------------
                  [
                  # List of all the trainers for the World Champions Tournament
                    [PBTrainers::CHAMPION_0,"Blue","So this is the standard over here...","Just as I expected! We were too much for you!","Kanto","Indigo Plateau"],
                    [PBTrainers::CHAMPION_1,"Lance","…It's over. But it's an odd feeling. I'm not angry that I lost. In fact, I feel happy.","I never give up, no matter what. You must be the same?","Johto","Indigo Plateau"],
                    [PBTrainers::CHAMPION_2,"Wallace","I, the Champion, fall in defeat... That was wonderful work.","The Pokémon you sent into battle...at times they were strong, at times they were weak. One day you will overcome your weakness.","Hoenn","Evergrande City"],
                    [PBTrainers::CHAMPION_3,"Cynthia","It seems that you are the most powerful Trainer.","For now, you're just a powerful challenger.","Sinnoh","Pokemon League"],
                    [PBTrainers::CHAMPION_4,"Iris","Aghhhh... I did my best, but we lost...","Hah! I knew that we could win!","Unova","Pokemon League"],
                    [PBTrainers::CHAMPION_5,"Alder","Well done! You certainly are an unmatched talent!","Use the battle with me as a stepping stone and move forward!","Unova","Pokemon League"],
                    [PBTrainers::CHAMPION_6,"Red","...\n...","...\n...","Kanto","Mt. Silver"],
                    [PBTrainers::CHAMPION_7,"Steven","I, the Champion, fall in defeat... Kudos to you, \PN! You are a truly noble Pokemon Trainer!","You might not have won today, but that does not make you a weak Trainer.","Hoenn","Evergrande City"]
                  ],
                  #-------------------------------------------------------------
                  # Generates the list for the Rental Masters Tournament
                  [ "slot reserved for Rental Masters Tournament" ],
                  #-------------------------------------------------------------
                  #-------------------------------------------------------------
                  # Generates the list for the Mix Masters Tournament
                  [ "slot reserved for Mix Masters Tournament" ]
                  #-------------------------------------------------------------
                ]
#===============================================================================

class PokemonWorldTournament
  
# Starts up the PWT system and generates missing trainer categories  
  def initialize(announce=false)
    @sprites={}
    @viewport=Viewport.new(0,0,Graphics.width,DEFAULTSCREENHEIGHT)
    @viewport.z=9999
    @sprites["scoreboard"]=Sprite.new(@viewport)
    @sprites["scoreboard"].bitmap=Bitmap.new(Graphics.width,DEFAULTSCREENHEIGHT)
    @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,DEFAULTSCREENHEIGHT,Color.new(0,0,0))
    @sprites["scoreboard"].opacity=0
    
    self.registerLevels
    
    $Trainer.battle_points=0 if !$Trainer.battle_points
    if !$Trainer.pwt_wins or $Trainer.pwt_wins.length < BATTLE_LIST.length
      $Trainer.pwt_wins=[]
      for i in 0...BATTLE_LIST.length
        $Trainer.pwt_wins.push(0)
      end
    end
        
    
    self.generateWorldLeaders if BATTLE_LIST.include?("World Leaders")
    self.generateRentalMasters if BATTLE_LIST.include?("Rental Masters")
    self.generateMixMasters if BATTLE_LIST.include?("Mix Masters")
    
    self.introduction
    @tournament_type = chooseTournament
    return cancelEntry if !@tournament_type
    @battle_type = chooseBattle
    return cancelEntry if !@battle_type
    @modified_party = choosePokemon
    if @modified_party=="notEligible"
      Kernel.pbMessage(_INTL("We're terribly sorry, but your Pokemon are not eligible for the Tournament."))
      Kernel.pbMessage(_INTL(showBanList))
      Kernel.pbMessage(_INTL("Please come back once your Pokemon Party has been adjusted."))
    elsif !@modified_party
      cancelEntry
    else
      self.generateRounds
      ret=self.startTournament(announce)
    end
    
    @sprites["scoreboard"].bitmap.clear
    @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,DEFAULTSCREENHEIGHT,Color.new(0,0,0))
    15.times do
      @sprites["scoreboard"].opacity-=17
      pbWait(1)
    end
    self.revertLevels
    case ret
    when "win"
      Kernel.pbMessage(_INTL("Congratulations on today's win."))
      Kernel.pbMessage(_INTL("For your victory you have earned 3 BP."))
      Kernel.pbMessage(_INTL("We hope to see you again."))
      $Trainer.pwt_wins[@tournament_type]+=1
      $Trainer.battle_points+=3
    when "loss"
      Kernel.pbMessage(_INTL("I'm sorry that you lost this tournament."))
      Kernel.pbMessage(_INTL("Maybe you'll have better luck next time."))
      cancelEntry
    end
  end
    
# The function used to generate the World Leaders Tournament trainers
  def generateWorldLeaders
    return if !BATTLE_LIST.include?("World Leaders")
    index = BATTLE_LIST.index("World Leaders")
    return false if index.nil?
    full_list = []
    for i in 0...index
      for j in 0...TRAINER_LIST[i].length
        full_list.push(TRAINER_LIST[i][j])
      end
    end
    trainers = []
    
    loop do
      n = rand(full_list.length)
      trainer = full_list[n]
      full_list.delete_at(n)
      trainers.push(trainer)
      break if trainers.length > 7
    end
          
    TRAINER_LIST[index] = trainers
  end  
  
# The function used to generate the RentalMasters Tournament trainers
  def generateRentalMasters
    return if !BATTLE_LIST.include?("Rental Masters")
    index = BATTLE_LIST.index("Rental Masters")
    return false if index.nil?
    full_list = []
    for i in 0...index
      next if !BATTLE_LIST.include?("World Leaders")
      if i!=BATTLE_LIST.index("World Leaders")
        for j in 0...TRAINER_LIST[i].length
          full_list.push(TRAINER_LIST[i][j])
        end
      end
    end
    trainers = []
    
    loop do
      n = rand(full_list.length)
      trainer = full_list[n]
      full_list.delete_at(n)
      trainers.push(trainer)
      break if trainers.length > 7
    end
          
    TRAINER_LIST[index] = trainers
  end  
  
# The function used to generate the RentalMasters Tournament trainers
  def generateMixMasters
    return if !BATTLE_LIST.include?("Mix Master")
    index = BATTLE_LIST.index("Mix Master")
    return false if index.nil?
    full_list = []
    for i in 0...index
      next if !BATTLE_LIST.include?("World Leaders") or !BATTLE_LIST.include?("Rental Masters")
      if i!=BATTLE_LIST.index("World Leaders") or i!=BATTLE_LIST.index("Rental Masters")
        for j in 0...TRAINER_LIST[i].length
          full_list.push(TRAINER_LIST[i][j])
        end
      end
    end
    trainers = []
    
    loop do
      n = rand(full_list.length)
      trainer = full_list[n]
      full_list.delete_at(n)
      trainers.push(trainer)
      break if trainers.length > 7
    end
          
    TRAINER_LIST[index] = trainers
  end  
 
# Creates a small introductory conversation
  def introduction
    Kernel.pbMessage(_INTL("Hello, and welcome to the Pokemon World Tournament!"))
    Kernel.pbMessage(_INTL("The place where the strongest gather to compete."))
  end
  
  def announceContest(trainer,i)
    n=rand(4)
    if i==7
      Kernel.pbMessage(_INTL("Announcer: Last but not least, joining us is our very own #{$Trainer.name}!")) if (@player_index==i)
      Kernel.pbMessage(_INTL("Announcer: Last but not least, joining our stadium is #{trainer[1]} from #{trainer[5]}, #{trainer[4]}!")) if !(@player_index==i)
      return true
    end
    case n
    when 0
      Kernel.pbMessage(_INTL("Announcer: Our local youth has talent too, please join me in welcoming #{$Trainer.name}!")) if (@player_index==i)
      Kernel.pbMessage(_INTL("Announcer: Visiting us all the way from #{trainer[5]}, #{trainer[4]}, is #{trainer[1]}!")) if !(@player_index==i)
    when 1
      Kernel.pbMessage(_INTL("Announcer: Spot no. #{i+1} takes a local trainer by the name, #{$Trainer.name}!")) if (@player_index==i)
      Kernel.pbMessage(_INTL("Announcer: Spot no. #{i+1} takes #{trainer[1]} from #{trainer[5]}, #{trainer[4]}!")) if !(@player_index==i)
    when 2
      Kernel.pbMessage(_INTL("Announcer: Our very own aspiring challenger #{$Trainer.name} is here to make a name for themself!")) if (@player_index==i)
      Kernel.pbMessage(_INTL("Announcer: From #{trainer[5]}, #{trainer[4]}, comes the legendary #{trainer[1]}!")) if !(@player_index==i)
    when 3
      Kernel.pbMessage(_INTL("Announcer: The next trainer is #{$Trainer.name} from our very own region!")) if (@player_index==i)
      Kernel.pbMessage(_INTL("Announcer: The next trainer is from #{trainer[5]}, #{trainer[4]}. Please, put your hands together for #{trainer[1]}!")) if !(@player_index==i)
    end
    
  end
  
# Cancels the entry into the Tournament
  def cancelEntry
    self.revertLevels
    Kernel.pbMessage(_INTL("We hope to see you again."))
    return false
  end
  
# Saves original Pokemon Levels  
  def registerLevels
    @party_levels=[]
    for pokemon in $Trainer.party
      @party_levels.push(pokemon.level)
    end
    @current_party = $Trainer.party.clone
  end
  
# Reverts Pokemon levels to original state
  def revertLevels
    $Trainer.party = @current_party
    for i in 0...@party_levels.length
      $Trainer.party[i].level = @party_levels[i]
      $Trainer.party[i].calcStats
      $Trainer.party[i].heal
    end
  end
  
# Creates a list of choices depending on the types of battles in BATTLE_LIST
  def chooseTournament
    choices = []
    for i in 0...BATTLE_LIST.index("World Leaders")
      choices.push(BATTLE_LIST[i])
    end
    if ($Trainer.pwt_wins[BATTLE_LIST.index("Kanto Leaders")] > 0 && 
        $Trainer.pwt_wins[BATTLE_LIST.index("Johto Leaders")] > 0 && 
        $Trainer.pwt_wins[BATTLE_LIST.index("Hoenn Leaders")] > 0 && 
        $Trainer.pwt_wins[BATTLE_LIST.index("Sinnoh Leaders")] > 0 &&
        $Trainer.pwt_wins[BATTLE_LIST.index("Unova Leaders")] > 0)
      choices.push("World Leaders")
    end
    if ($Trainer.pwt_wins[BATTLE_LIST.index("World Champions")] > 0)
      choices.push("Rental Masters")
    end
    if ($Trainer.pwt_wins[BATTLE_LIST.index("World Champions")] > 0)
      choices.push("Mix Master")
    end
    if ($Trainer.pwt_wins[BATTLE_LIST.index("World Leaders")] > 0)
      choices.push("World Champions")
    end
    choices.push("Cancel")
    cmd=Kernel.pbMessage(_INTL("Which Tournament would you like to participate in?"),choices,choices.index("Cancel"))
    return false if choices[cmd]=="Cancel"
    return cmd
  end
  
# Allows the player to choose which style of battle they would like to do
  def chooseBattle
    choices = ["Single","Double","Full","Sudden Death","Cancel"]
    cmd=Kernel.pbMessage(_INTL("Which type of Battle would you like to participate in?"),choices,choices.length-1)
    return false if cmd==choices.length-1
    return cmd
  end
  
# Checks if the party is eligible
  def partyEligible?
    length = [3,4,6,1][@battle_type]
    count=0
    return false if $Trainer.party.length < length
    for i in 0...$Trainer.party.length
      count+=1 if !(BAN_LIST.include?($Trainer.party[i].species)) && !($Trainer.party[i].egg?)
    end
    
    return true if count >= length
    return false
  end

# Creates a new trainer party based on the battle type, and the Pokemon chosen to enter
  def choosePokemon
    ret=false
    return "notEligible" if !partyEligible?
    length = [3,4,6,1][@battle_type]
    Kernel.pbMessage(_INTL("Please choose the Pokemon you would like to participate."))
    ruleset=PokemonRuleSet.new
    ruleset.addPokemonRule(RestrictSpecies.new)
    ruleset.setNumberRange(length,length)
    pbFadeOutIn(99999){
       scene=PokemonScreen_Scene.new
       screen=PokemonScreen.new(scene,$Trainer.party)
       ret=screen.pbPokemonMultipleEntryScreenEx(ruleset)
    }
    return ret
  end
  
# Creates the initial trainer list for the first round, depending on the category chosen
  def generateRounds
    for i in 0...@modified_party.length
      @modified_party[i].level=50
      @modified_party[i].calcStats
    end
    
    @trainer_list = []
    full_list = TRAINER_LIST[@tournament_type]
    
    loop do
      n = rand(full_list.length)
      trainer = full_list[n]
      full_list.delete_at(n)
      @trainer_list.push(trainer)
      break if @trainer_list.length > 7
    end
    
    n = rand(8)
    @player_index = n
    @player_index_int = @player_index
    for i in 0...@trainer_list.length
      @trainer_list[i].push("Leader_#{@trainer_list[i][1]}") if @trainer_list[i][6].nil?
    end
    @trainer_list[n] = @modified_party    
    $Trainer.party = @modified_party
    @trainer_list_int=@trainer_list
  end
  
# Outputs a message which lists all the Pokemon banned from the Tournament
  def showBanList
    msg = ""
    for i in 0...BAN_LIST.length
      
      pkmn = PokeBattle_Pokemon.new(BAN_LIST[i],1,nil,false)
      msg+="#{pkmn.name}, "
    end
    msg+="and Eggs are not eligible for entry in the Tournament."
    
    return msg
  end
  
# Handles the tournament branch
# and adds some additional flavour such as an announcer talking
  def startTournament(announce)
    @round=0
    doublebattle=false
    doublebattle=true if @battle_type==1
    15.times do
      @sprites["scoreboard"].opacity+=17
      pbWait(1)
    end
    Kernel.pbMessage(_INTL("Announcer: Welcome to the #{BATTLE_LIST[@tournament_type]} Tournament!"))
    Kernel.pbMessage(_INTL("Announcer: Today we have 8 very eager contestants, waiting to compete for the title of \"Champion\"."))
    Kernel.pbMessage(_INTL("Announcer: Let us turn our attention to the scoreboard, to see who will be competing today."))
    self.createScoreBoard(@trainer_list)
    for i in 0...8
      announceContest(@trainer_list[i],i) if announce
    end
    Kernel.pbMessage(_INTL("Announcer: Without further ado, let the first match begin."))
    trainer=self.generateRound1
    Kernel.pbMessage(_INTL("Announcer: This will be a battle between #{$Trainer.name} and #{trainer[1]}."))
    outcome=pbPWTTrainerBattle(trainer[0],trainer[1],trainer[2],trainer[3],doublebattle)
    if outcome==1
      @round=1
      Kernel.pbMessage(_INTL("Announcer: Wow! What an exciting first round!"))
      Kernel.pbMessage(_INTL("Announcer: The stadium is getting heated up, and the contestants are on fire!"))
      Kernel.pbMessage(_INTL("Announcer: Let us turn our attention back to the scoreboard for the results."))
      trainer=self.generateRound2
      self.createScoreBoard(@trainer_list)
      Kernel.pbMessage(_INTL("Announcer: It looks like the next match will be between #{$Trainer.name} and #{trainer[1]}."))
      Kernel.pbMessage(_INTL("Announcer: Let the battle begin!"))
      outcome=pbPWTTrainerBattle(trainer[0],trainer[1],trainer[2],trainer[3],doublebattle)
      if outcome==1
        @round=2
        Kernel.pbMessage(_INTL("Announcer: What spectacular matches!"))
        Kernel.pbMessage(_INTL("Announcer: These trainers are really giving it all."))
        Kernel.pbMessage(_INTL("Announcer: Let's direct our attention at the scoreboard one final time."))
        trainer=self.generateRound3
        self.createScoreBoard(@trainer_list)
        Kernel.pbMessage(_INTL("Announcer: Alright! It's all set!"))
        Kernel.pbMessage(_INTL("Announcer: The final match of this tournament will be between #{$Trainer.name} and #{trainer[1]}!"))
        Kernel.pbMessage(_INTL("Announcer: May the best trainer win!"))
        outcome=pbPWTTrainerBattle(trainer[0],trainer[1],trainer[2],trainer[3],doublebattle)
        if outcome==1
          Kernel.pbMessage(_INTL("Announcer: What an amazing battle!"))
          Kernel.pbMessage(_INTL("Announcer: Both the trainers put up a great fight, but our very own #{$Trainer.name} was the one to come out on top!"))
          Kernel.pbMessage(_INTL("Announcer: Congratulations #{$Trainer.name}! You have certainly earned today's title of \"Champion\"!"))

          Kernel.pbMessage(_INTL("Announcer: That's all we have time for. I hope you enjoyed todays contest. And we hope to see you again soon."))
          return "win"
        end
      end
    end
    return "loss"
  end
  
# Creates a basic Image illustrating a scoreboard
  def createScoreBoard(list)
    nlist=[]
    for i in 0...list.length
      nlist.push(list[i][0])
    end
    x=0
    y=0
    @sprites["scoreboard"].bitmap.clear
    @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,DEFAULTSCREENHEIGHT,Color.new(0,0,0))
    @sprites["scoreboard"].bitmap.blt(0,0,BitmapCache.load_bitmap("Graphics/Pictures/scoreboard"),Rect.new(0,0,Graphics.width,DEFAULTSCREENHEIGHT))
    pbSetSystemFont(@sprites["scoreboard"].bitmap)
    for i in 0...@trainer_list_int.length
      opacity=255
      if i==@player_index_int
        trname="#{$Trainer.name}"
        meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
        char=pbGetPlayerCharset(meta,1)
        bitmap=BitmapCache.load_bitmap("Graphics/Characters/#{char}")
      else
        opacity=80 if !(nlist.include?(@trainer_list_int[i][0]))
        trname=@trainer_list_int[i][1]
        bitmap=BitmapCache.load_bitmap("Graphics/Characters/#{@trainer_list_int[i][6]}")
      end
      @sprites["scoreboard"].bitmap.blt(20+(Graphics.width-24-(bitmap.width/4))*x,20+(DEFAULTSCREENHEIGHT/6)*y,bitmap,Rect.new(0,0,bitmap.width/4,bitmap.height/4),opacity)
      text=[["#{trname}",24+(bitmap.width/4)+(Graphics.width-32-(bitmap.width/2))*x,34+(DEFAULTSCREENHEIGHT/6)*y,x*1,Color.new(255,255,255),Color.new(80,80,80)]]
      pbDrawTextPositions(@sprites["scoreboard"].bitmap,text)
      y+=1
      x+=1 if y > 3
      y=0 if y > 3
    end
      
  end
    
# Heals your party
  def healParty
    for pokemon in $Trainer.party
      pokemon.heal
    end
  end

  def generateRound1
    healParty
    trainer = @trainer_list[[1,0,3,2,5,4,7,6][@player_index]]
    return trainer
  end
  
  def generateRound2
    healParty
    list=["","","",""]
    @player_index = @player_index/2
    for i in 0...4
      if i == @player_index
        list[i] = @modified_party
      else
        list[i] = @trainer_list[(i*2)+rand(2)]
      end
    end
    @trainer_list=list
    trainer = @trainer_list[[1,0,3,2][@player_index]]
    return trainer
  end
  
  def generateRound3
    healParty
    list=["","","",""]
    @player_index = @player_index/2
    for i in 0...2
      if i == @player_index
        list[i] = @modified_party
      else
        list[i] = @trainer_list[(i*2)+rand(2)]
      end
    end
    @trainer_list=list
    trainer = @trainer_list[[1,0][@player_index]]
    return trainer
  end

end

#===============================================================================
# PWT battle rules
#===============================================================================
class RestrictSpecies
  def initialize
    @specieslist=BAN_LIST.clone
  end
  def isSpecies?(species,specieslist)
    for s in specieslist
      return true if species==s
    end
    return false  
  end
  def isValid?(pokemon)
    count=0
    if isSpecies?(pokemon.species,@specieslist) && !(pokemon.egg?)
      count+=1
    end
    return count==0
  end
end

#===============================================================================
# Exta classes and functions for PWT trainer and battle generation
#===============================================================================

class PokeBattle_Trainer
  attr_accessor(:battle_points)
  attr_accessor(:pwt_wins)
end

# Generates a new PWT styled trainer, where the party is randomized (from the options in the trainer party definition of PBS/trainers.txt)
def pbPWTLoadTrainer(trainerid,trainername,partyid=0)
  trainer = pbLoadTrainer(trainerid,trainername,partyid)
  return nil if trainer.nil?
  opponent = trainer[0]
  items = trainer[1]
  party = trainer[2]
  length = [3,4,6,1][@battle_type]
  old_party = party.clone
  new_party = []
  count = 0
  loop do
    n=rand(old_party.length)
    new_party.push(old_party[n])
    old_party.delete_at(n)
    break if new_party.length >= length
  end
  party = new_party.clone 
  return [opponent,items,party]
end

# Creates the PWT styled battle, where exp gain, money gain and switching is disabled
def pbPWTTrainerBattle(trainerid,trainername,endspeech,endspeechwin,doublebattle=false,trainerparty=0,canlose=true)
  if $Trainer.pokemonCount==0
    Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
    return false
  end
  trainer=pbPWTLoadTrainer(trainerid,trainername,trainerparty)
  if !trainer
    pbMissingTrainer(trainerid,trainername,trainerparty)
    return false
  end
  playerparty=$Trainer.party
  playertrainer=$Trainer
  fullparty1=false
  scene=pbNewBattleScene
  battle=PokeBattle_Battle.new(scene,playerparty,trainer[2],playertrainer,trainer[0])
  battle.fullparty1=fullparty1
  battle.doublebattle=doublebattle
  battle.endspeech=endspeech
  battle.endspeechwin=endspeechwin
  battle.items=trainer[1]
  trainerbgm="PWT Finals.mp3" if @round==2 && !(["World Champions","Rental Masters","Mix Master"].include?(BATTLE_LIST[@tournament_type]))
  if Input.press?(Input::CTRL) && $DEBUG
    Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
    Kernel.pbMessage(_INTL("AFTER LOSING..."))
    Kernel.pbMessage(battle.endspeech)
    return true
  end
  Events.onStartBattle.trigger(nil,nil)
  battle.internalbattle=false
  pbPrepareBattle(battle)
  restorebgm=true
  decision=0
  pbBattleAnimation(trainer[0].trainertype,trainer[0].name) { 
     pbSceneStandby {
        decision=battle.pbStartBattle(canlose)
     }
     for i in $Trainer.party
       i.makeUnmega rescue nil
       i.makeUnprimal if INCLUDEGEN6
     end
  }
  Input.update
  return decision
end
 
Last edited:

JokerBen

Director of Pokémon Nobelium
241
Posts
11
Years
  • Age 23
  • Seen Aug 29, 2023
This might be a bit of a stretch, but I'm going try this anyway. Would there be a way to store the latest opponents in a variable to use in a conditional branch? Just like in B2W2, after you participate in the PWT, your opponents are in the lobby and they have a few things to say or to be able to set custom move routes (FL's addon) based on the opponent in case their sprite is limited to them not being able to walk. This would be neat to have. Any guidance is greatly appreciated.

EDIT: Would there also be a way for tournaments to be unlocked? Like if the player has eight badges, then the Kanto Leaders tournament is unlocked or something. I'm just looking for a way to implement switches into the script.
 
Last edited:

FL

Pokémon Island Creator
2,444
Posts
13
Years
  • Seen Apr 22, 2024
This might be a bit of a stretch, but I'm going try this anyway. Would there be a way to store the latest opponents in a variable to use in a conditional branch? Just like in B2W2, after you participate in the PWT, your opponents are in the lobby and they have a few things to say or to be able to set custom move routes (FL's addon) based on the opponent in case their sprite is limited to them not being able to walk. This would be neat to have. Any guidance is greatly appreciated.

EDIT: Would there also be a way for tournaments to be unlocked? Like if the player has eight badges, then the Kanto Leaders tournament is unlocked or something. I'm just looking for a way to implement switches into the script.
For unlocking tournaments, before line 'if BATTLE_LIST.include?("World Leaders") && allBasicTournametBeated' add:

Code:
if BATTLE_LIST.include?("Switch Tournament 1") && $game_switches[72]
  choices.push("Switch Tournament 1")
end

Switch 72 activates tournament named "Switch Tournament 1".

For storing opponents that you battled in variables, look at lines 'trainer=self.generateRound1', 'trainer=self.generateRound2' and 'trainer=self.generateRound3'. After these lines, you can get trainer IDs in 'trainer[0]' and the name in 'trainer[1]'. Just remember to clear these values each start of a new tournament (the start of def startTournament should be a good place).
 
18
Posts
7
Years
  • Age 28
  • Seen Apr 17, 2023
PWT

Hi! I tried to use the Luka's PWT script on my game. When I select Kanto Leaders, the announcer starts talking. When he says "to see who will be compiting today", it happens this:
http://i.imgur.com/u2ERjyA.png
what could I do? thanks
 
33
Posts
7
Years
Pokémon World Tournament Error

I installed the Pokémon World Tournament script from Luka S.J and it was working just fine.
Then I edited the overworld music and then the game has been giving me these messages.
It doesn't crash just displays the messages and then the game plays just fine.
Please help!
screenshot1.png

screenshot2.png

screenshot3.png
 
37
Posts
7
Years
  • Age 34
  • Seen today
I got the very same issue icsir3 just posted and would really appreciate any possible help!
 
36
Posts
8
Years
  • Age 30
  • Seen May 22, 2021
Sorry, I am lost and I do not know how to initiate PWT battles, I have been trying to figure out since days. Please help.

Is it using this script?

Conditional Branch:Script:pbPWTLoadTrainer(PBTrainers::Leader_0,"Brock",1)
 
5
Posts
4
Years
  • Age 26
  • Seen Sep 25, 2023
Hi, nice feature, but is there a way to make the tournament schedule bigger? Like 32 battles in the same tournament
 

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
Hi, I have no idea on how to start it from the overworld by using an NPC. Any help?

You can find the full set of instructions on my archived page, here: [LINK]
I'll update the main thread to include this information as it's currently highly out of date.
 
62
Posts
5
Years
The download doesn't start... apparently the button from the archived page you shared doesn't do anything :/
 

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
The download doesn't start... apparently the button from the archived page you shared doesn't do anything :/

The download is not on that page, it's an old archive. You implied that you already have it in your system and want to know how to use it. That page contains the instructions; but as I've said I would do yesterday anyway, I already updated the first post of the thread to include all the relevant information.
 
Back
Top