Advertisement
Guest User

Crude edit of Luka's PWT + FL's Edits

a guest
Feb 20th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 34.22 KB | None | 0 0
  1. #===============================================================================
  2. # Pokemon World Tournament script created by Luka S.J.
  3. # Please give credit when used
  4. #===============================================================================
  5. # Place the script above Main and you're ready to go. This script aims to
  6. # provide a full PWT experience for Essentials (minus the nice visual part).
  7. # I've even gone a little further, and added some things not present in the
  8. # official PWT.
  9. # Call it in a script/even script as PokemonWorldTournament.new
  10. #
  11. #===============================================================================
  12. # Settings
  13. #===============================================================================
  14.   ELITEBATTLE = (PokeBattle_Scene.method_defined?(:animateBattleSprites)) ? true : false
  15.   INCLUDEGEN6 = (PokeBattle_Scene.method_defined?(:pbDisplayEffect)) ? true : false
  16. # Here you can configure the various aspects of the system.
  17. # Trainers should be defined through the editor, or the PBS file, but should be
  18. # linked/called here just the same way you would in a normal trainer event
  19. #
  20. # This is a list of the types of battles available
  21. # Make sure that World Leaders is in the list after all the other Gym Leader
  22. # Tournament branches.
  23.   BATTLE_LIST = [
  24.                   "Kanto Leaders",
  25.                   "Johto Leaders",
  26.                   "Hoenn Leaders",
  27.                   "Sinnoh Leaders",
  28.                   "Unova Leaders",
  29.                   "World Leaders",
  30.                   "World Champions",
  31.                   "Rental Masters", # not yet implemented
  32.                   "Mix Master" # not yet implemented
  33.                 ]
  34. # This is a list of the Pokemon that cannot be used in the PWT                
  35.   BAN_LIST = [
  36.               PBSpecies::MEWTWO,
  37.               PBSpecies::MEW,
  38.               PBSpecies::HOOH,
  39.               PBSpecies::LUGIA,
  40.               PBSpecies::CELEBI,
  41.               PBSpecies::KYOGRE,
  42.               PBSpecies::GROUDON,
  43.               PBSpecies::RAYQUAZA,
  44.               PBSpecies::DEOXYS,
  45.               PBSpecies::JIRACHI,
  46.               PBSpecies::DIALGA,
  47.               PBSpecies::PALKIA,
  48.               PBSpecies::GIRATINA,
  49.               PBSpecies::HEATRAN,
  50.               PBSpecies::DARKRAI,
  51.               PBSpecies::SHAYMIN,
  52.               PBSpecies::ARCEUS,
  53.               PBSpecies::ZEKROM,
  54.               PBSpecies::RESHIRAM,
  55.               PBSpecies::KYUREM,
  56.               PBSpecies::LANDORUS,
  57.               PBSpecies::MELOETTA,
  58.               PBSpecies::KELDEO,
  59.               PBSpecies::GENESECT
  60.             ]
  61.                  
  62. # This is the list of all the defined trainers
  63. # Trainers are defined as arrays containing:
  64. # [ 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) ]
  65. #
  66. # The index of the trainer list has to correspond with the category type.
  67. # If you're creating your own trainer list, make sure it has at least 8 entries, otherwise it won't work.
  68.   TRAINER_LIST = [
  69.                   #-------------------------------------------------------------
  70.                   [
  71.                   # List of all the trainers for the Kanto Leaders Tournament
  72.                     [PBTrainers::LEADER_0,"Brock","Looks like you were the sturdier of us.","My barrier was tough to break. Maybe next time.","Kanto","Pewter City"],
  73.                     [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"],
  74.                     [PBTrainers::LEADER_2,"Lt.Surge","You shocked my very core, soldier!","At ease son, not everyone can beat me.","Kanto","Vermillion City"],
  75.                     [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"],
  76.                     [PBTrainers::LEADER_4,"Sabrina","Impossible! I did not predict this!","The outcome was just as I predicted.","Kanto","Saffron City"],
  77.                     [PBTrainers::LEADER_5,"Janine","You've got a great battle technique!","My technique was the superior one!","Kanto","Fuchsia City"],
  78.                     [PBTrainers::LEADER_6,"Blaine","Your flame burnt me up!","My flames are not something everyone can handle.","Kanto","Cinnabar Island"],
  79.                     [PBTrainers::LEADER_7,"Giovanni","What? \nMe, lose?!","I could have never lost to a kid like you!","Kanto","Viridian City"]
  80.                   ],
  81.                   #-------------------------------------------------------------
  82.                   #-------------------------------------------------------------
  83.                   [
  84.                   # List of all the trainers for the Johto Leaders Tournament
  85.                     [PBTrainers::LEADER_8,"Falkner","I understand... I'll bow out gracefully.","My birds and I will always fly!","Johto","Violet City"],
  86.                     [PBTrainers::LEADER_9,"Bugsy","Aw, that's the end of it...","My tough Bug Pokemon cannot be defeated easily.","Johto","Azlea Town"],
  87.                     [PBTrainers::LEADER_10,"Whitney","Ugh...","You really are strong! But I won't lose to you!","Johto","Goldenrod City"],
  88.                     [PBTrainers::LEADER_11,"Morty","How is this possible...","We've got more discipline than anyone else!","Johto","Ecruteak City"],
  89.                     [PBTrainers::LEADER_12,"Chuck","We...lost...","No... Not...yet...","Johto","Cianwood City"],
  90.                     [PBTrainers::LEADER_13,"Jasmine","Well done...","Steel will hang on to the very last!","Johto","Olivine City"],
  91.                     [PBTrainers::LEADER_14,"Pryce","Hmm. Seems as if my luck has run out.","My luck has not run out just yet.","Johto","Mahogany Town"],
  92.                     [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"]
  93.                   ],
  94.                   #-------------------------------------------------------------
  95.                   #-------------------------------------------------------------
  96.                   [
  97.                   # List of all the trainers for the Hoenn Leaders Tournament
  98.                     [PBTrainers::LEADER_16,"Roxanne","So... I lost...","I learned many things from our battle.","Hoenn","Rustboro City"],
  99.                     [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"],
  100.                     [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"],
  101.                     [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"],
  102.                     [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"],
  103.                     [PBTrainers::LEADER_21,"Winona","A Trainer that commands Pokémon with more grace than I...","Our elegant dance is finished!","Hoenn","Fortree City"],
  104.                     [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"],
  105.                     [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"]
  106.                   ],
  107.                   #-------------------------------------------------------------
  108.                   #-------------------------------------------------------------
  109.                   [
  110.                   # List of all the trainers for the Sinnoh Leaders Tournament
  111.                     [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"],
  112.                     [PBTrainers::LEADER_26,"Gardenia","Amazing! You're very good, aren't you?","You did not have me concerned at all.","Sinnoh","Eterna City"],
  113.                     [PBTrainers::LEADER_27,"Fantina","You are so fantastically strong. I know now why I have lost.","Never give up, never surrender!","Sinnoh","Hearthome City"],
  114.                     [PBTrainers::LEADER_28,"Mayleene","I shall admit defeat... You are much too strong.","I take battling very seriously.","Sinnoh","Veilstone City"],
  115.                     [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"],
  116.                     [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"],
  117.                     [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"],
  118.                     [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"]
  119.                   ],
  120.                   #-------------------------------------------------------------
  121.                   #-------------------------------------------------------------
  122.                   [
  123.                   # List of all the trainers for the Unova Leaders Tournament
  124.                     [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"],
  125.                     [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"],
  126.                     [PBTrainers::LEADER_35,"Burgh","Is it over? Has my muse abandoned me?"," bug Pokémon are scurrying with excitement of battling!","Unova","Castelia City"],
  127.                     [PBTrainers::LEADER_36,"Elesa","I meant to make your head spin, but you shocked me instead.","My Pokemon shined brilliantly!","Unova","Nimbasa City"],
  128.                     [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"],
  129.                     [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"],
  130.                     [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"],
  131.                     [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"]
  132.                   ],
  133.                   #-------------------------------------------------------------
  134.                   # Generates the list for the World Leaders Tournament
  135.                   [ "slot reserved for World Leaders Tournament" ],
  136.                   #-------------------------------------------------------------
  137.                   #-------------------------------------------------------------
  138.                   [
  139.                   # List of all the trainers for the World Champions Tournament
  140.                     [PBTrainers::CHAMPION_0,"Blue","So this is the standard over here...","Just as I expected! We were too much for you!","Kanto","Indigo Plateau"],
  141.                     [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"],
  142.                     [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"],
  143.                     [PBTrainers::CHAMPION_3,"Cynthia","It seems that you are the most powerful Trainer.","For now, you're just a powerful challenger.","Sinnoh","Pokemon League"],
  144.                     [PBTrainers::CHAMPION_4,"Iris","Aghhhh... I did my best, but we lost...","Hah! I knew that we could win!","Unova","Pokemon League"],
  145.                     [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"],
  146.                     [PBTrainers::CHAMPION_6,"Red","...\n...","...\n...","Kanto","Mt. Silver"],
  147.                     [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"]
  148.                   ],
  149.                   #-------------------------------------------------------------
  150.                   # Generates the list for the Rental Masters Tournament
  151.                   [ "slot reserved for Rental Masters Tournament" ],
  152.                   #-------------------------------------------------------------
  153.                   #-------------------------------------------------------------
  154.                   # Generates the list for the Mix Masters Tournament
  155.                   [ "slot reserved for Mix Masters Tournament" ]
  156.                   #-------------------------------------------------------------
  157.                 ]
  158. #===============================================================================
  159.  
  160. class PokemonWorldTournament
  161.  
  162. # Starts up the PWT system and generates missing trainer categories  
  163.   attr_accessor :round
  164.   attr_accessor :won
  165.   attr_accessor :finished
  166.   def initialize(announce=false)
  167.     @announce=announce
  168.     @finished=false
  169.     @won=false
  170.   end
  171.  
  172.   def start
  173.     @sprites={}
  174.     @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  175.     @viewport.z=9999
  176.     @sprites["scoreboard"]=Sprite.new(@viewport)
  177.     @sprites["scoreboard"].bitmap=Bitmap.new(Graphics.width,Graphics.height)
  178.     @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0))
  179.     @sprites["scoreboard"].opacity=0
  180.  
  181.     self.registerLevels
  182.    
  183.     $Trainer.battle_points=0 if !$Trainer.battle_points
  184.     if !$Trainer.pwt_wins or $Trainer.pwt_wins.length<BATTLE_LIST.length
  185.       $Trainer.pwt_wins=[]
  186.       for i in 0...BATTLE_LIST.length
  187.         $Trainer.pwt_wins.push(0)
  188.       end
  189.     end
  190.      
  191.  
  192.     self.generateWorldLeaders if BATTLE_LIST.include?("World Leaders")
  193.     self.generateRentalMasters if BATTLE_LIST.include?("Rental Masters")
  194.     self.generateMixMasters if BATTLE_LIST.include?("Mix Masters")
  195.  
  196.     self.introduction
  197.     @tournament_type = chooseTournament
  198.     return cancelEntry if !@tournament_type
  199.     @battle_type = chooseBattle
  200.     return cancelEntry if !@battle_type
  201.     @modified_party = choosePokemon
  202.     if @modified_party=="notEligible"
  203.       Kernel.pbMessage(_INTL("We're terribly sorry, but your Pokemon are not eligible for the Tournament."))
  204.       Kernel.pbMessage(_INTL(showBanList))
  205.       Kernel.pbMessage(_INTL("Please come back once your Pokemon Party has been adjusted."))
  206.     elsif !@modified_party
  207.       cancelEntry
  208.     else
  209.       self.generateRounds
  210.       return true
  211.     end
  212.     return false
  213.   end
  214.  
  215.   def endTournament(win)
  216.     @sprites["scoreboard"].bitmap.clear
  217.     @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0))
  218.     if win
  219.       Kernel.pbMessage(_INTL("Congratulations on today's win."))
  220.       Kernel.pbMessage(_INTL("For your victory you have earned 3 BP."))
  221.       Kernel.pbMessage(_INTL("We hope to see you again."))
  222.       $Trainer.pwt_wins[@tournament_type]+=1
  223.       $Trainer.battle_points+=3
  224.     else # loss
  225.       Kernel.pbMessage(_INTL("I'm sorry that you lost this tournament."))
  226.       Kernel.pbMessage(_INTL("Maybe you'll have better luck next time."))
  227.       cancelEntry
  228.     end
  229.     $Trainer.party = @current_party
  230.   end
  231.    
  232. # The function used to generate the World Leaders Tournament trainers
  233.   def generateWorldLeaders
  234.     return if !BATTLE_LIST.include?("World Leaders")
  235.     index = BATTLE_LIST.index("World Leaders")
  236.     return false if index.nil?
  237.     full_list = []
  238.     for i in 0...index
  239.       for j in 0...TRAINER_LIST[i].length
  240.         full_list.push(TRAINER_LIST[i][j])
  241.       end
  242.     end
  243.     trainers = []
  244.    
  245.     loop do
  246.       n = rand(full_list.length)
  247.       trainer = full_list[n]
  248.       full_list.delete_at(n)
  249.       trainers.push(trainer)
  250.       break if trainers.length>7
  251.     end
  252.          
  253.     TRAINER_LIST[index] = trainers
  254.   end  
  255.  
  256. # The function used to generate the RentalMasters Tournament trainers
  257.   def generateRentalMasters
  258.     return if !BATTLE_LIST.include?("Rental Masters")
  259.     index = BATTLE_LIST.index("Rental Masters")
  260.     return false if index.nil?
  261.     full_list = []
  262.     for i in 0...index
  263.       next if !BATTLE_LIST.include?("World Leaders")
  264.       if i!=BATTLE_LIST.index("World Leaders")
  265.         for j in 0...TRAINER_LIST[i].length
  266.           full_list.push(TRAINER_LIST[i][j])
  267.         end
  268.       end
  269.     end
  270.     trainers = []
  271.    
  272.     loop do
  273.       n = rand(full_list.length)
  274.       trainer = full_list[n]
  275.       full_list.delete_at(n)
  276.       trainers.push(trainer)
  277.       break if trainers.length>7
  278.     end
  279.          
  280.     TRAINER_LIST[index] = trainers
  281.   end  
  282.  
  283. # The function used to generate the RentalMasters Tournament trainers
  284.   def generateMixMasters
  285.     return if !BATTLE_LIST.include?("Mix Master")
  286.     index = BATTLE_LIST.index("Mix Master")
  287.     return false if index.nil?
  288.     full_list = []
  289.     for i in 0...index
  290.       next if !BATTLE_LIST.include?("World Leaders") or !BATTLE_LIST.include?("Rental Masters")
  291.       if i!=BATTLE_LIST.index("World Leaders") or i!=BATTLE_LIST.index("Rental Masters")
  292.         for j in 0...TRAINER_LIST[i].length
  293.           full_list.push(TRAINER_LIST[i][j])
  294.         end
  295.       end
  296.     end
  297.     trainers = []
  298.    
  299.     loop do
  300.       n = rand(full_list.length)
  301.       trainer = full_list[n]
  302.       full_list.delete_at(n)
  303.       trainers.push(trainer)
  304.       break if trainers.length>7
  305.     end
  306.          
  307.     TRAINER_LIST[index] = trainers
  308.   end  
  309.  
  310. # Creates a small introductory conversation
  311.   def introduction
  312.     Kernel.pbMessage(_INTL("Hello, and welcome to the Pokemon World Tournament!"))
  313.     Kernel.pbMessage(_INTL("The place where the strongest gather to compete."))
  314.   end
  315.  
  316.   def announceContest(trainer,i)
  317.     n=rand(4)
  318.     if i==7
  319.       Kernel.pbMessage(_INTL("Announcer: Last but not least, joining us is our very own #{$Trainer.name}!")) if (@player_index==i)
  320.       Kernel.pbMessage(_INTL("Announcer: Last but not least, joining our stadium is #{trainer[1]} from #{trainer[5]}, #{trainer[4]}!")) if !(@player_index==i)
  321.       return true
  322.     end
  323.     case n
  324.     when 0
  325.       Kernel.pbMessage(_INTL("Announcer: Our local youth has talent too, please join me in welcoming #{$Trainer.name}!")) if (@player_index==i)
  326.       Kernel.pbMessage(_INTL("Announcer: Visiting us all the way from #{trainer[5]}, #{trainer[4]}, is #{trainer[1]}!")) if !(@player_index==i)
  327.     when 1
  328.       Kernel.pbMessage(_INTL("Announcer: Spot no. #{i+1} takes a local trainer by the name, #{$Trainer.name}!")) if (@player_index==i)
  329.       Kernel.pbMessage(_INTL("Announcer: Spot no. #{i+1} takes #{trainer[1]} from #{trainer[5]}, #{trainer[4]}!")) if !(@player_index==i)
  330.     when 2
  331.       Kernel.pbMessage(_INTL("Announcer: Our very own aspiring challenger #{$Trainer.name} is here to make a name for themself!")) if (@player_index==i)
  332.       Kernel.pbMessage(_INTL("Announcer: From #{trainer[5]}, #{trainer[4]}, comes the legendary #{trainer[1]}!")) if !(@player_index==i)
  333.     when 3
  334.       Kernel.pbMessage(_INTL("Announcer: The next trainer is #{$Trainer.name} from our very own region!")) if (@player_index==i)
  335.       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)
  336.     end
  337.    
  338.   end
  339.  
  340. # Cancels the entry into the Tournament
  341.   def cancelEntry
  342.     self.revertLevels
  343.     Kernel.pbMessage(_INTL("We hope to see you again."))
  344.     return false
  345.   end
  346.  
  347. # Saves original Pokemon Levels  
  348.   def registerLevels
  349.     @party_levels=[]
  350.     for pokemon in $Trainer.party
  351.       @party_levels.push(pokemon.level)
  352.     end
  353.     @current_party = $Trainer.party.clone
  354.   end
  355.  
  356. # Reverts Pokemon levels to original state
  357.   def revertLevels
  358.     $Trainer.party = @current_party
  359.     for i in 0...@party_levels.length
  360.       $Trainer.party[i].level = @party_levels[i]
  361.       $Trainer.party[i].calcStats
  362.       $Trainer.party[i].heal
  363.     end
  364.   end
  365.  
  366. # Creates a list of choices depending on the types of battles in BATTLE_LIST
  367.   def chooseTournament
  368.     choices = []
  369.     for i in 0...BATTLE_LIST.index("World Leaders")
  370.       choices.push(BATTLE_LIST[i])
  371.     end
  372.     if ($Trainer.pwt_wins[BATTLE_LIST.index("Kanto Leaders")]>0 &&
  373.         $Trainer.pwt_wins[BATTLE_LIST.index("Johto Leaders")]>0 &&
  374.         $Trainer.pwt_wins[BATTLE_LIST.index("Hoenn Leaders")]>0 &&
  375.         $Trainer.pwt_wins[BATTLE_LIST.index("Sinnoh Leaders")]>0 &&
  376.         $Trainer.pwt_wins[BATTLE_LIST.index("Unova Leaders")]>0)
  377.       choices.push("World Leaders")
  378.     end
  379.     if ($Trainer.pwt_wins[BATTLE_LIST.index("World Champions")]>0)
  380.       choices.push("Rental Masters")
  381.     end
  382.     if ($Trainer.pwt_wins[BATTLE_LIST.index("World Champions")]>0)
  383.       choices.push("Mix Master")
  384.     end
  385.     if ($Trainer.pwt_wins[BATTLE_LIST.index("World Leaders")]>0)
  386.       choices.push("World Champions")
  387.     end
  388.     choices.push("Cancel")
  389.     cmd=Kernel.pbMessage(_INTL("Which Tournament would you like to participate in?"),choices,choices.index("Cancel"))
  390.     return false if choices[cmd]=="Cancel"
  391.     return cmd
  392.   end
  393.  
  394. # Allows the player to choose which style of battle they would like to do
  395.   def chooseBattle
  396.     choices = ["Single","Double","Full","Sudden Death","Cancel"]
  397.     cmd=Kernel.pbMessage(_INTL("Which type of Battle would you like to participate in?"),choices,choices.length-1)
  398.     return false if cmd==choices.length-1
  399.     return cmd
  400.   end
  401.  
  402. # Checks if the party is eligible
  403.   def partyEligible?
  404.     length = [3,4,6,1][@battle_type]
  405.     count=0
  406.     return false if $Trainer.party.length<length
  407.     for i in 0...$Trainer.party.length
  408.       count+=1 if !(BAN_LIST.include?($Trainer.party[i].species)) && !($Trainer.party[i].egg?)
  409.     end
  410.    
  411.     return true if count>=length
  412.     return false
  413.   end
  414.  
  415. # Creates a new trainer party based on the battle type, and the Pokemon chosen to enter
  416.   def choosePokemon
  417.     ret=false
  418.     return "notEligible" if !partyEligible?
  419.     length = [3,4,6,1][@battle_type]
  420.     Kernel.pbMessage(_INTL("Please choose the Pokemon you would like to participate."))
  421.     ruleset=PokemonRuleSet.new
  422.     ruleset.addPokemonRule(RestrictSpecies.new)
  423.     ruleset.setNumberRange(length,length)
  424.     pbFadeOutIn(99999){
  425.        scene=PokemonScreen_Scene.new
  426.        screen=PokemonScreen.new(scene,$Trainer.party)
  427.        ret=screen.pbPokemonMultipleEntryScreenEx(ruleset)
  428.     }
  429.     return ret
  430.   end
  431.  
  432. # Creates the initial trainer list for the first round, depending on the category chosen
  433.   def generateRounds
  434.     for i in 0...@modified_party.length
  435.       @modified_party[i].level=50
  436.       @modified_party[i].calcStats
  437.     end
  438.    
  439.     @trainer_list = []
  440.     full_list = TRAINER_LIST[@tournament_type].clone
  441.    
  442.     loop do
  443.       n = rand(full_list.length)
  444.       trainer = full_list[n]
  445.       full_list.delete_at(n)
  446.       @trainer_list.push(trainer)
  447.       break if @trainer_list.length>7
  448.     end
  449.    
  450.     n = rand(8)
  451.     @player_index = n
  452.     @player_index_int = @player_index
  453.     for i in 0...@trainer_list.length
  454.       @trainer_list[i][6]="Leader_#{@trainer_list[i][1]}" if @trainer_list[i][6].nil?
  455.     end
  456.     @trainer_list[n] = @modified_party    
  457.     $Trainer.party = @modified_party
  458.     @trainer_list_int=@trainer_list
  459.   end
  460.  
  461. # Outputs a message which lists all the Pokemon banned from the Tournament
  462.   def showBanList
  463.     msg = ""
  464.     for i in 0...BAN_LIST.length
  465.      
  466.       pkmn = PokeBattle_Pokemon.new(BAN_LIST[i],1,nil,false)
  467.       msg+="#{pkmn.name}, "
  468.     end
  469.     msg+="and Eggs are not eligible for entry in the Tournament."
  470.    
  471.     return msg
  472.   end
  473.  
  474. # Handles the tournament branch
  475. # and adds some additional flavour such as an announcer talking
  476.   def announcerRound1
  477.     Kernel.pbMessage(_INTL("Announcer: Welcome to the #{BATTLE_LIST[@tournament_type]} Tournament!"))
  478.     Kernel.pbMessage(_INTL("Announcer: Today we have 8 very eager contestants, waiting to compete for the title of \"Champion\"."))
  479.     Kernel.pbMessage(_INTL("Announcer: Let us turn our attention to the scoreboard, to see who will be competing today."))
  480.     self.createScoreBoard(@trainer_list)
  481.     @sprites["scoreboard"].opacity=255
  482.     for i in 0...8
  483.       announceContest(@trainer_list[i],i) if @announce
  484.     end
  485.     Kernel.pbMessage(_INTL("Announcer: Without further ado, let the first match begin."))
  486.     @nextTrainer=self.generateRound1
  487.     Kernel.pbMessage(_INTL("Announcer: This will be a battle between #{$Trainer.name} and #{@nextTrainer[1]}."))
  488.     @sprites["scoreboard"].opacity=0
  489.   end
  490.    
  491.   def announcerRound2
  492.     Kernel.pbMessage(_INTL("Announcer: Wow! What an exciting first round!"))
  493.     Kernel.pbMessage(_INTL("Announcer: The stadium is getting heated up, and the contestants are on fire!"))
  494.     Kernel.pbMessage(_INTL("Announcer: Let us turn our attention back to the scoreboard for the results."))
  495.     @nextTrainer=self.generateRound2
  496.     self.createScoreBoard(@trainer_list)
  497.     @sprites["scoreboard"].opacity=255
  498.     Kernel.pbMessage(_INTL("Announcer: It looks like the next match will be between #{$Trainer.name} and #{@nextTrainer[1]}."))
  499.     Kernel.pbMessage(_INTL("Announcer: Let the battle begin!"))
  500.     @sprites["scoreboard"].opacity=0
  501.   end
  502.  
  503.   def announcerRound3
  504.     Kernel.pbMessage(_INTL("Announcer: What spectacular matches!"))
  505.     Kernel.pbMessage(_INTL("Announcer: These trainers are really giving it all."))
  506.     Kernel.pbMessage(_INTL("Announcer: Let's direct our attention at the scoreboard one final time."))
  507.     @nextTrainer=self.generateRound3
  508.     self.createScoreBoard(@trainer_list)
  509.     @sprites["scoreboard"].opacity=255
  510.     Kernel.pbMessage(_INTL("Announcer: Alright! It's all set!"))
  511.     Kernel.pbMessage(_INTL("Announcer: The final match of this tournament will be between #{$Trainer.name} and #{@nextTrainer[1]}!"))
  512.     Kernel.pbMessage(_INTL("Announcer: May the best trainer win!"))
  513.     @sprites["scoreboard"].opacity=0
  514.   end
  515.  
  516.   def winTournament
  517.     Kernel.pbMessage(_INTL("Announcer: What an amazing battle!"))
  518.     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!"))
  519.     Kernel.pbMessage(_INTL("Announcer: Congratulations #{$Trainer.name}! You have certainly earned today's title of \"Champion\"!"))
  520.     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."))
  521.   end
  522.  
  523.   def beforeBattleMessage
  524.     outbattleMessage(7)
  525.   end  
  526.  
  527.   def afterBattleWinMessage
  528.     outbattleMessage(8)
  529.   end
  530.  
  531.   def afterBattleLoseMessage
  532.     outbattleMessage(9)
  533.   end
  534.  
  535.   def outbattleMessage(listIndex)
  536.     if @nextTrainer[listIndex]
  537.       dialogueLines=@nextTrainer[listIndex].is_a?(Array) ? @nextTrainer[listIndex] : [@nextTrainer[listIndex]]
  538.       for line in dialogueLines
  539.         Kernel.pbMessage(line)
  540.       end  
  541.     end  
  542.   end  
  543.  
  544.   def battle
  545.     trainerid=@nextTrainer[0]
  546.     trainername=@nextTrainer[1]
  547.     endspeech=@nextTrainer[2]
  548.     endspeechwin=@nextTrainer[3]
  549.     doublebattle=@battle_type==1
  550.     return pbPWTTrainerBattle(trainerid,trainername,endspeech,endspeechwin, doublebattle)
  551.   end  
  552.  
  553.   def setEventGraphic(event)
  554.     filename = @nextTrainer[6]
  555.     begin
  556.       bitmap=BitmapCache.load_bitmap("Graphics/Characters/#{filename}")
  557.       bitmap.dispose
  558.       event.character_name=filename
  559.     rescue
  560.       event.character_name="trchar000"
  561.     end
  562.   end
  563.  
  564. # Creates a basic Image illustrating a scoreboard
  565.   def createScoreBoard(list)
  566.     nlist=[]
  567.     for i in 0...list.length
  568.       nlist.push(list[i][0])
  569.     end
  570.     x=0
  571.     y=0
  572.     @sprites["scoreboard"].bitmap.clear
  573.     @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0))
  574.     @sprites["scoreboard"].bitmap.blt(0,0,BitmapCache.load_bitmap("Graphics/Pictures/scoreboard"),Rect.new(0,0,Graphics.width,Graphics.height))
  575.     pbSetSystemFont(@sprites["scoreboard"].bitmap)
  576.     for i in 0...@trainer_list_int.length
  577.       opacity=255
  578.       if i==@player_index_int
  579.         trname="#{$Trainer.name}"
  580.         meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
  581.         char=pbGetPlayerCharset(meta,1)
  582.         bitmap=BitmapCache.load_bitmap("Graphics/Characters/#{char}")
  583.       else
  584.         opacity=80 if !(nlist.include?(@trainer_list_int[i][0]))
  585.         trname=@trainer_list_int[i][1]
  586.         bitmap=BitmapCache.load_bitmap("Graphics/Characters/#{@trainer_list_int[i][6]}")
  587.       end
  588.       @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)
  589.       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)]]
  590.       pbDrawTextPositions(@sprites["scoreboard"].bitmap,text)
  591.       y+=1
  592.       x+=1 if y>3
  593.       y=0 if y>3
  594.     end
  595.      
  596.   end
  597.    
  598. # Heals your party
  599.   def healParty
  600.     for pokemon in $Trainer.party
  601.       pokemon.heal
  602.     end
  603.   end
  604.  
  605.   def generateRound1
  606.     healParty
  607.     trainer = @trainer_list[[1,0,3,2,5,4,7,6][@player_index]]
  608.     return trainer
  609.   end
  610.  
  611.   def generateRound2
  612.     healParty
  613.     list=["","","",""]
  614.     @player_index = @player_index/2
  615.     for i in 0...4
  616.       if i == @player_index
  617.         list[i] = @modified_party
  618.       else
  619.         list[i] = @trainer_list[(i*2)+rand(2)]
  620.       end
  621.     end
  622.     @trainer_list=list
  623.     trainer = @trainer_list[[1,0,3,2][@player_index]]
  624.     return trainer
  625.   end
  626.  
  627.   def generateRound3
  628.     healParty
  629.     list=["","","",""]
  630.     @player_index = @player_index/2
  631.     for i in 0...2
  632.       if i == @player_index
  633.         list[i] = @modified_party
  634.       else
  635.         list[i] = @trainer_list[(i*2)+rand(2)]
  636.       end
  637.     end
  638.     @trainer_list=list
  639.     trainer = @trainer_list[[1,0][@player_index]]
  640.     return trainer
  641.   end
  642.  
  643. end
  644.  
  645. #===============================================================================
  646. # PWT battle rules
  647. #===============================================================================
  648. class RestrictSpecies
  649.  def initialize
  650.   @specieslist=BAN_LIST.clone
  651.  end
  652.  def isSpecies?(species,specieslist)
  653.   for s in specieslist
  654.    return true if species==s
  655.   end
  656.   return false  
  657.  end
  658.  def isValid?(pokemon)
  659.    count=0
  660.     if isSpecies?(pokemon.species,@specieslist) && !(pokemon.egg?)
  661.      count+=1
  662.     end
  663.    return count==0
  664.  end
  665. end
  666.  
  667. #===============================================================================
  668. # Exta classes and functions for PWT trainer and battle generation
  669. #===============================================================================
  670.  
  671. class PokeBattle_Trainer
  672.   attr_accessor(:battle_points)
  673.   attr_accessor(:pwt_wins)
  674. end
  675.  
  676. # Generates a new PWT styled trainer, where the party is randomized (from the options in the trainer party definition of PBS/trainers.txt)
  677. def pbPWTLoadTrainer(trainerid,trainername,partyid=0)
  678.   trainer = pbLoadTrainer(trainerid,trainername,partyid)
  679.   return nil if trainer.nil?
  680.   opponent = trainer[0]
  681.   items = trainer[1]
  682.   party = trainer[2]
  683.   length = [3,4,6,1][@battle_type]
  684.   old_party = party.clone
  685.     new_party=[]
  686.     count=0
  687.     loop do
  688.       n=rand(old_party.length)
  689.       new_party.push(old_party[n])
  690.       old_party.delete_at(n)
  691.       break if new_party.length>=length
  692.     end
  693.   party = new_party.clone
  694.   return [opponent,items,party]
  695. end
  696.  
  697. # Creates the PWT styled battle, where exp gain, money gain and switching is disabled
  698. def pbPWTTrainerBattle(trainerid,trainername,endspeech,endspeechwin,doublebattle=false,trainerparty=0,canlose=true)
  699.   if $Trainer.pokemonCount==0
  700.     Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
  701.     return false
  702.   end
  703.   trainer=pbPWTLoadTrainer(trainerid,trainername,trainerparty)
  704.   if !trainer
  705.     pbMissingTrainer(trainerid,trainername,trainerparty)
  706.     return false
  707.   end
  708.   playerparty=$Trainer.party
  709.   playertrainer=$Trainer
  710.   fullparty1=false
  711.   scene=pbNewBattleScene
  712.   battle=PokeBattle_Battle.new(scene,playerparty,trainer[2],playertrainer,trainer[0])
  713.   battle.fullparty1=fullparty1
  714.   battle.doublebattle=doublebattle
  715.   battle.endspeech=endspeech
  716.   battle.endspeechwin=endspeechwin
  717.   battle.items=trainer[1]
  718.   trainerbgm=pbGetTrainerBattleBGM(trainer[0])
  719.   trainerbgm="PWT Finals.mp3" if @round==2 && !(["World Champions","Rental Masters","Mix Master"].include?(BATTLE_LIST[@tournament_type]))
  720.   if Input.press?(Input::CTRL) && $DEBUG
  721.     Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
  722.     Kernel.pbMessage(_INTL("AFTER LOSING..."))
  723.     Kernel.pbMessage(battle.endspeech)
  724.     return true
  725.   end
  726.   Events.onStartBattle.trigger(nil,nil)
  727.   battle.internalbattle=false
  728.   pbPrepareBattle(battle)
  729.   restorebgm=true
  730.   decision=0
  731.   pbBattleAnimation(trainerbgm,trainer[0].trainertype,trainer[0].name) {
  732.      pbSceneStandby {
  733.         decision=battle.pbStartBattle(canlose)
  734.      }
  735.      for i in $Trainer.party
  736.          i.makeUnmega rescue nil
  737.        i.makeUnprimal if INCLUDEGEN6
  738.      end
  739.   }
  740.   Input.update
  741.   return decision
  742. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement