The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Reply
 
Thread Tools
  #1    
Old February 16th, 2014, 01:03 PM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
Ok, it actually is not that simple, but neither is it as complex as the original one in BW2. I know a lot of people wanted this feature, so I've written a 100% stock-Essentials-compatible PWT system (just for you guys...from scratch...) I suggest studying the code a bit, in case you want to do any adjustments. I've tried to make the code as n00b friendly as possible, but there is always the possibility of that not being the case.

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,Graphics.height)
    @viewport.z=9999
    @sprites["scoreboard"]=Sprite.new(@viewport)
    @sprites["scoreboard"].bitmap=Bitmap.new(Graphics.width,Graphics.height)
    @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0))
    @sprites["scoreboard"].opacity=0
    
    $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
        
    @current_party = $Trainer.party
    
    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,Graphics.height,Color.new(0,0,0))
    15.times do
      @sprites["scoreboard"].opacity-=17
      pbWait(1)
    end
    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
    $Trainer.party = @current_party
  end
    
# The function used to generate the World Leaders Tournament trainers
  def generateWorldLeaders
    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
    index = BATTLE_LIST.index("Rental Masters")
    return false if index.nil?
    full_list = []
    for i in 0...index
      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
    index = BATTLE_LIST.index("Mix Master")
    return false if index.nil?
    full_list = []
    for i in 0...index
      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
    Kernel.pbMessage(_INTL("We hope to see you again."))
    return false
  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?
    case @battle_type
    when 0
      length = 3
    when 1
      length = 4
    when 2 
      length = 6
    when 3
      length = 1
    end
    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?
    case @battle_type
    when 0
      length = 3
    when 1
      length = 4
    when 2 
      length = 6
    when 3
      length = 1
    end
    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,Graphics.height,Color.new(0,0,0))
    @sprites["scoreboard"].bitmap.blt(0,0,BitmapCache.load_bitmap("Graphics/Pictures/scoreboard"),Rect.new(0,0,Graphics.width,Graphics.height))
    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+(Graphics.height/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+(Graphics.height/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
    case @player_index
    when 0
      trainer=@trainer_list[1]
    when 1
      trainer=@trainer_list[0]
    when 2
      trainer=@trainer_list[3]
    when 3
      trainer=@trainer_list[2]
    when 4
      trainer=@trainer_list[5]
    when 5
      trainer=@trainer_list[4]
    when 6
      trainer=@trainer_list[7]
    when 7
      trainer=@trainer_list[6]
    end
    return trainer
  end
  
  def generateRound2
    healParty
    list=["","","",""]
    case @player_index
    when 0
      @player_index=0
      list[0]=@modified_party
      list[1]=@trainer_list[2+rand(2)]
      list[2]=@trainer_list[4+rand(2)]
      list[3]=@trainer_list[6+rand(2)]
    when 1
      @player_index=0
      list[0]=@modified_party
      list[1]=@trainer_list[2+rand(2)]
      list[2]=@trainer_list[4+rand(2)]
      list[3]=@trainer_list[6+rand(2)]
    when 2
      @player_index=1
      list[1]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
      list[2]=@trainer_list[4+rand(2)]
      list[3]=@trainer_list[6+rand(2)]
    when 3
      @player_index=1
      list[1]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
      list[2]=@trainer_list[4+rand(2)]
      list[3]=@trainer_list[6+rand(2)]
    when 4
      @player_index=2
      list[2]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
      list[1]=@trainer_list[2+rand(2)]
      list[3]=@trainer_list[6+rand(2)]
    when 5
      @player_index=2
      list[2]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
      list[1]=@trainer_list[2+rand(2)]
      list[3]=@trainer_list[6+rand(2)]
    when 6
      @player_index=3
      list[3]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
      list[1]=@trainer_list[2+rand(2)]
      list[2]=@trainer_list[4+rand(2)]
    when 7
      @player_index=3
      list[3]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
      list[1]=@trainer_list[2+rand(2)]
      list[2]=@trainer_list[4+rand(2)]
    end
    @trainer_list=list
    case @player_index
    when 0
      trainer=@trainer_list[1]
    when 1
      trainer=@trainer_list[0]
    when 2
      trainer=@trainer_list[3]
    when 3
      trainer=@trainer_list[2]
    end
    return trainer
  end
  
  def generateRound3
    healParty
    list=["","","",""]
    case @player_index
    when 0
      @player_index=0
      list[0]=@modified_party
      list[1]=@trainer_list[2+rand(2)]
    when 1
      @player_index=0
      list[0]=@modified_party
      list[1]=@trainer_list[2+rand(2)]
    when 2
      @player_index=1
      list[1]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
    when 3
      @player_index=1
      list[1]=@modified_party
      list[0]=@trainer_list[0+rand(2)]
    end
    @trainer_list=list
    case @player_index
    when 0
      trainer=@trainer_list[1]
    when 1
      trainer=@trainer_list[0]
    end
    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)
  success=false
  items=[]
  party=[]
  opponent=nil
  trainers=load_data("Data/trainers.dat")
  case @battle_type
  when 0
    length = 3
  when 1
    length = 4
  when 2 
    length = 6
  when 3
    length = 1
  end
  for trainer in trainers
    name=trainer[1]
    thistrainerid=trainer[0]
    thispartyid=trainer[4]
    next if trainerid!=thistrainerid || name!=trainername || partyid!=thispartyid
    items=trainer[2].clone
    name=pbGetMessageFromHash(MessageTypes::TrainerNames,name)
    for i in RIVALNAMES
      if isConst?(trainerid,PBTrainers,i[0]) && $game_variables[i[1]]!=0
        name=$game_variables[i[1]]
      end
    end
    opponent=PokeBattle_Trainer.new(name,thistrainerid)
    opponent.setForeignID($Trainer) if $Trainer
    for poke in trainer[3]
      species=poke[TPSPECIES]
      level=poke[TPLEVEL]
      pokemon=PokeBattle_Pokemon.new(species,level,opponent)
      pokemon.form=poke[TPFORM]
      pokemon.resetMoves
      pokemon.item=poke[TPITEM]
      if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>0
        k=0
        for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
          pokemon.moves[k]=PBMove.new(poke[move])
          k+=1
        end
        pokemon.moves.compact!
      end
      pokemon.setAbility(poke[TPABILITY])
      pokemon.setGender(poke[TPGENDER])
      if poke[TPSHINY]   # if this is a shiny Pokémon
        pokemon.makeShiny
      else
        pokemon.makeNotShiny
      end
      pokemon.setNature(poke[TPNATURE])
      iv=poke[TPIV]
      for i in 0...6
        pokemon.iv[i]=iv&0x1F
        pokemon.ev[i]=[85,level*3/2].min
      end
      pokemon.happiness=poke[TPHAPPINESS]
      pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
      if poke[TPSHADOW]   # if this is a Shadow Pokémon
        pokemon.makeShadow rescue nil
        pokemon.pbUpdateShadowMoves(true) rescue nil
        pokemon.makeNotShiny
      end
      pokemon.ballused=poke[TPBALL]
      pokemon.calcStats
      party.push(pokemon)
    end
    old_party=party
    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
    success=true
    break
  end
  return success ? [opponent,items,party] : nil
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
  if !$PokemonTemp.waitingTrainer && $Trainer.ablePokemonCount>1 &&
     pbMapInterpreterRunning?
    thisEvent=pbMapInterpreter.get_character(0)
    triggeredEvents=$game_player.pbTriggeredTrainerEvents([2],false)
    otherEvent=[]
    for i in triggeredEvents
      if i.id!=thisEvent.id && !$game_self_switches[[$game_map.map_id,i.id,"A"]]
        otherEvent.push(i)
      end
    end
    if otherEvent.length==1
      trainer=pbLoadTrainer(trainerid,trainername,trainerparty)
      if !trainer
        pbMissingTrainer(trainerid,trainername,trainerparty)
        return false
      end
      if trainer[2].length<=3
        $PokemonTemp.waitingTrainer=[trainer,thisEvent.id,endspeech,doublebattle]
        return false
      end
    end
  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=pbGetTrainerBattleBGM(trainer[0])
  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)
    Kernel.pbMessage(battle.endspeech2) if battle.endspeech2
    if $PokemonTemp.waitingTrainer
      pbMapInterpreter.pbSetSelfSwitch(
         $PokemonTemp.waitingTrainer[1],"A",true
      )
      $PokemonTemp.waitingTrainer=nil
    end
    return true
  end
  Events.onStartBattle.trigger(nil,nil)
  battle.internalbattle=false
  pbPrepareBattle(battle)
  restorebgm=true
  decision=0
  pbBattleAnimation(trainerbgm,trainer[0].trainertype,trainer[0].name) { 
     pbSceneStandby {
        decision=battle.pbStartBattle(canlose)
     }
     for i in $Trainer.party; (i.makeUnmega rescue nil); end
     if $PokemonGlobal.partner
       pbHealAll
       for i in $PokemonGlobal.partner[3]
         i.heal
         i.makeUnmega rescue nil
       end
     end
     if decision==2 || decision==5
       if canlose
         for i in $Trainer.party; i.heal; end
         for i in 0...10
           Graphics.update
         end
       else
         $game_system.bgm_unpause
         $game_system.bgs_unpause
         Kernel.pbStartOver
       end
     else
       Events.onEndBattle.trigger(nil,decision)
       if decision==1
         if $PokemonTemp.waitingTrainer
           pbMapInterpreter.pbSetSelfSwitch(
              $PokemonTemp.waitingTrainer[1],"A",true
           )
         end
       end
     end
  }
  Input.update
  $PokemonTemp.waitingTrainer=nil
  return decision
end
The basic things you need to know is how to call the system. You call it with PokemonWorldTournament.new. A lot of what you need to know is written in the comments so please look at them. The main part is defining/declaring trainers. Trainers are created as usual through the Editor or PBS files, and then you have to link it in the TRAINER_LIST array. The exact format of it is written in the comments. I've actually done all the trainers for gen 1 up to gen 5 inclusive. So you have all the leaders and champions done. What you need now are the resources. I've actually also compiled a Resource Pack for you guys (includes some graphics, one required, audio files and the trainer PBS). Please put that into your games. One note though, do not simply replace your PBS files, but rather add the stuff from my PBS files to yours, and adjust the index of the trainertypes if necessary.

The system is not 100% complete. I really couldn't keep on going anymore after all those hours I put in it today. The Rental Masters and Mix Master modes are missing, which I'll try to get done tomorrow. The visual aspects of this PWT are kinda meh, so if anyone tweaks the code, makes it better, and wants to share it - please do. Copy the script above Main and you're good to go. It should work, without any problems (unless it's interfering with custom scripts - then I can't do anything about that). I've added some things not present in the official PWT, to compensate for the lack of Rotation and Triple battles (nothing I can do there).


Final note, resources that you need, and that will break the system if not present:
"Graphics/Pictures/scoreboard"
"Graphics/Characters/name_of_leader_sprites" <= by default these are "Leader_nameofleader", so "Leader_Brock" for example, but you can specify your own sprite names in the trainer arrays
__________________
[STOPPED][DEMO] Pokemon Blue Chrome
[DEVELOPING] S.J.Ware
[DEVELOPING] Tykanite

Last edited by Luka S.J.; April 3rd, 2014 at 12:45 AM. Reason: Resource Pack upgrade + Added Hoenn speeches
Reply With Quote
  #2    
Old February 16th, 2014, 02:54 PM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
Guys, whoever got the script several hours ago, replace it with the amended version. I forgot to add some stuff which would make your PWT experience terrible
Reply With Quote
  #3    
Old February 16th, 2014, 06:36 PM
Worldslayer608's Avatar
Worldslayer608
ಥдಥ
Community Supporter
 
Join Date: Mar 2008
Location: San Diego
Age: 25
Gender: Male
Nature: Calm
Really excited to check this out Luka! Unfortunately it is going to have to hold off a couple days

REALLY appreciate you sharing this though, whether I use it or not I think it is a great add-on for Essentials users. Probably the best in my opinion.
__________________


Pokemon Pillars of Destiny - Starters
To vanquish without peril is to triumph without glory...

Voted Best Game Designer 2011 on PC
Reply With Quote
  #4    
Old February 17th, 2014, 01:04 PM
RPD490's Avatar
RPD490
 
Join Date: Jan 2009
Location: Blackthorn City, Johto
Gender: Male
Nature: Relaxed
I been waiting for something like this to pop up, great job!
__________________
Reply With Quote
  #5    
Old February 21st, 2014, 10:17 AM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
Minor Update:

I've upgraded the Resource Pack to include all the Trainer sprites for all the trainertypes defined in the PBS. I've also added the win and lose speeches for the Hoenn Leaders, that were not there before. Also, I've adjusted the code so that there is no limit on how many trainer entries you can put for the tournament branch in the array TRAINER_LIST (used to be 8 before). The Resource Pack is still missing OW sprites of the Leaders and Champions from Hoenn and Unova, as they do not officially exist in Gen IV format. You will not be able to play those Tournament branches, unless you add the missing OW sprites to your game.

Rental and Mix Master modes are still not available. I will add that soon.

Sidenote:

Keep in mind that to unlock "World Leaders" you need to beat all the other Gym Leader type Tournaments at least once. And to unlock "World Champions" you need to beat "World Leaders" at least once.

Last edited by Luka S.J.; February 21st, 2014 at 10:23 AM.
Reply With Quote
  #6    
Old March 30th, 2014, 12:24 PM
Giu's Avatar
Giu
 
Join Date: Jan 2010
Gender: Male
Nature: Modest
Hi,

This seems to be really great, but I am not being able to test it.

Whenever I try to participate in any tournament with any team, it always displays the following message:
"We're terribly sorry, but your Pokemon are not eligible for the Tournament."
Then a list of the banned pokémon follows (none of which is in my party, nor do I have any eggs).
"Please come back once your Pokemon Party has been adjusted."

I believe it may be due to some little mistake in the script. Can anyone else confirm this?

Thank you!
__________________

Check out my DeviantArt account! My game project is called Pokemon Subrosia.
My DeviantArt | Old DeviantArt
Reply With Quote
  #7    
Old March 30th, 2014, 12:52 PM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
Quote:
Originally Posted by Giu View Post
Hi,

This seems to be really great, but I am not being able to test it.

Whenever I try to participate in any tournament with any team, it always displays the following message:
"We're terribly sorry, but your Pokemon are not eligible for the Tournament."
Then a list of the banned pokémon follows (none of which is in my party, nor do I have any eggs).
"Please come back once your Pokemon Party has been adjusted."

I believe it may be due to some little mistake in the script. Can anyone else confirm this?

Thank you!
What type of tournament are you trying to participate in, and how many Pokemon do you have in your team? Your party may not be eligible if you do not have enough Pokemon in your team to participate in the tournament.

Single Battle requires at least 3 in your party. Double requires 4. Full Battle needs a full party of 6. And Sudden Death only needs 1.

Last edited by Luka S.J.; March 30th, 2014 at 12:59 PM.
Reply With Quote
  #8    
Old March 30th, 2014, 07:10 PM
Giu's Avatar
Giu
 
Join Date: Jan 2010
Gender: Male
Nature: Modest
Quote:
Originally Posted by Luka S.J. View Post
What type of tournament are you trying to participate in, and how many Pokemon do you have in your team? Your party may not be eligible if you do not have enough Pokemon in your team to participate in the tournament.

Single Battle requires at least 3 in your party. Double requires 4. Full Battle needs a full party of 6. And Sudden Death only needs 1.
I had a party of six pokémon, and I tryed to participate in each regional tournament both in single and double battles. Just tryed it again using Essentials demo-party, in a new game, still got the error.
Are you using the same script that is on the page? Maybe yours is a little bit different.
__________________

Check out my DeviantArt account! My game project is called Pokemon Subrosia.
My DeviantArt | Old DeviantArt

Last edited by Giu; March 30th, 2014 at 07:25 PM.
Reply With Quote
  #9    
Old March 31st, 2014, 12:49 PM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
Quote:
Originally Posted by Giu View Post
I had a party of six pokémon, and I tryed to participate in each regional tournament both in single and double battles. Just tryed it again using Essentials demo-party, in a new game, still got the error.
Are you using the same script that is on the page? Maybe yours is a little bit different.
If your def partyEligible? looks like this
Code:
  def partyEligible?
    case @battle_type
    when 0
      length = 3
    when 1
      length = 4
    when 2 
      length = 6
    when 3
      length = 1
    end
    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
Then you should be getting the same results as me; which is a playable PWT. The code in this thread, is the code I'm running in my game, and everything works just fine.
Reply With Quote
  #10    
Old March 31st, 2014, 05:41 PM
Giu's Avatar
Giu
 
Join Date: Jan 2010
Gender: Male
Nature: Modest
Thank you for the quick repply.

If you look at the original code carefully, there is a little mistake, which is not in this new one you just showed me. Take a look:

Original Code:
Code:
    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
Correct Code:
Code:
    return false if $Trainer.party.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
Now that I changed it, the Tournament is working fine.
Thank you for sharing the code. It's really cool.
I'll work on it a little bit. I want to tweak it, so that it will be more viasually appealing. I'll show you in case I get anything nice.
Cheers!
__________________

Check out my DeviantArt account! My game project is called Pokemon Subrosia.
My DeviantArt | Old DeviantArt

Last edited by Giu; March 31st, 2014 at 05:54 PM.
Reply With Quote
  #11    
Old March 31st, 2014, 06:58 PM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
Quote:
Originally Posted by Giu View Post
Thank you for the quick repply.

If you look at the original code carefully, there is a little mistake, which is not in this new one you just showed me. Take a look:

Original Code:
Code:
    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
Correct Code:
Code:
    return false if $Trainer.party.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
Now that I changed it, the Tournament is working fine.
Thank you for sharing the code. It's really cool.
I'll work on it a little bit. I want to tweak it, so that it will be more viasually appealing. I'll show you in case I get anything nice.
Cheers!
That's not a mistake, it's intentional. The original code is the correct one (what do you mean new code anyway? I just copied and pasted the same thing from the OP). Your team cannot be eligible if you do not have enough Pokemon in your party to participate. The line is supposed to be return false if $Trainer.party.length < length. What you just did with your "correct code" is remove that functionality, and goofed it up. I just tested all the branches and all the types of tournaments with the "original" code, and everything works just as it should.

Long story short: your "correct code" is not correct. Go through the logic there. What you've done now, is make partyEligible? return a false value (meaning party is not eligible) whenever $Trainer.party.length (that statement will always be true if it isn't 0). That means, that whenever your party is larger than 0, your team will not be eligible. At this stage, I have no idea what you're doing anymore.

Last edited by Luka S.J.; April 3rd, 2014 at 12:45 AM.
Reply With Quote
  #12    
Old April 1st, 2014, 05:35 PM
Giu's Avatar
Giu
 
Join Date: Jan 2010
Gender: Male
Nature: Modest
Quote:
Originally Posted by Luka S.J. View Post
That's not a mistake, it's intentional. The original code is the correct one (what do you mean new code anyway? I just copied and pasted the same thing from the OP). Your team cannot be eligible if you do not have enough Pokemon in your party to participate. The line is supposed to be return false if $Trainer.party.length<length. What you just did with your "correct code" is remove that functionality, and goofed it up. I just tested all the branches and all the types of tournaments with the "original" code, and everything works just as it should.

Long story short: your "correct code" is not correct. Go through the logic there. What you've done now, is make partyEligible? return a false value (meaning party is not eligible) whenever $Trainer.party.length (that statement will always be true if it isn't 0). That means, that whenever your party is larger than 0, your team will not be eligible. At this stage, I have no idea what you're doing anymore.
Sorry, maybe I was a little bit confusiong in my last post.
I didn't write or modify any of those codes. I did not write the "correct code".

By original code I mean the code I just copy & pasted from your first post in this thread (the complete script). It contained: (and was not working properly)
Code:
return false if $Trainer.party.length<length
By correct code, I mean the code I just copy & pasted from your previous post, which contained: (and is working fine)
Code:
return false if $Trainer.party.length
Sorry for the confusion regarding this. I believe that part of the code from you last post (which I called the "correct code") is indeed correct (and I confirm, the PWT is working fine now that I'm using it). On the other hand, the main code of this thread was not working becuase it is different from your last code. There should'nt be a <lenght there I guess.
__________________

Check out my DeviantArt account! My game project is called Pokemon Subrosia.
My DeviantArt | Old DeviantArt

Last edited by Giu; April 1st, 2014 at 05:41 PM.
Reply With Quote
  #13    
Old April 3rd, 2014, 12:44 AM
Luka S.J.'s Avatar
Luka S.J.
S.J.Ware HD
 
Join Date: Dec 2008
Age: 21
Gender: Male
Nature: Adamant
WTF? When looking at this thread through Chrome the <length part appears, when looking at it through Safari it does not. I don't know what's going on there but there should be a < length for the eligibility check. That I'm sure of.
__________________
[STOPPED][DEMO] Pokemon Blue Chrome
[DEVELOPING] S.J.Ware
[DEVELOPING] Tykanite
Reply With Quote
  #14    
Old April 3rd, 2014, 01:04 PM
Rayd12smitty's Avatar
Rayd12smitty
Shadow Maker
 
Join Date: Dec 2011
Gender: Male
This is so weird... I'm on safari and both quotes are identical, on chrome the one is fixed and the other isn't. This is kinda cool, but really annoying
__________________
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 03:27 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.