Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # 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
- #===============================================================================
- ELITEBATTLE = (PokeBattle_Scene.method_defined?(:animateBattleSprites)) ? true : false
- INCLUDEGEN6 = (PokeBattle_Scene.method_defined?(:pbDisplayEffect)) ? true : false
- # 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
- attr_accessor :round
- attr_accessor :won
- attr_accessor :finished
- def initialize(announce=false)
- @announce=announce
- @finished=false
- @won=false
- end
- def start
- @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
- self.registerLevels
- $Trainer.battle_points=0 if !$Trainer.battle_points
- if !$Trainer.pwt_wins or $Trainer.pwt_wins.length<BATTLE_LIST.length
- $Trainer.pwt_wins=[]
- for i in 0...BATTLE_LIST.length
- $Trainer.pwt_wins.push(0)
- end
- end
- self.generateWorldLeaders if BATTLE_LIST.include?("World Leaders")
- self.generateRentalMasters if BATTLE_LIST.include?("Rental Masters")
- self.generateMixMasters if BATTLE_LIST.include?("Mix Masters")
- self.introduction
- @tournament_type = chooseTournament
- return cancelEntry if !@tournament_type
- @battle_type = chooseBattle
- return cancelEntry if !@battle_type
- @modified_party = choosePokemon
- if @modified_party=="notEligible"
- Kernel.pbMessage(_INTL("We're terribly sorry, but your Pokemon are not eligible for the Tournament."))
- Kernel.pbMessage(_INTL(showBanList))
- Kernel.pbMessage(_INTL("Please come back once your Pokemon Party has been adjusted."))
- elsif !@modified_party
- cancelEntry
- else
- self.generateRounds
- return true
- end
- return false
- end
- def endTournament(win)
- @sprites["scoreboard"].bitmap.clear
- @sprites["scoreboard"].bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0))
- if 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
- else # 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
- return if !BATTLE_LIST.include?("World Leaders")
- index = BATTLE_LIST.index("World Leaders")
- return false if index.nil?
- full_list = []
- for i in 0...index
- for j in 0...TRAINER_LIST[i].length
- full_list.push(TRAINER_LIST[i][j])
- end
- end
- trainers = []
- loop do
- n = rand(full_list.length)
- trainer = full_list[n]
- full_list.delete_at(n)
- trainers.push(trainer)
- break if trainers.length>7
- end
- TRAINER_LIST[index] = trainers
- end
- # The function used to generate the RentalMasters Tournament trainers
- def generateRentalMasters
- return if !BATTLE_LIST.include?("Rental Masters")
- index = BATTLE_LIST.index("Rental Masters")
- return false if index.nil?
- full_list = []
- for i in 0...index
- next if !BATTLE_LIST.include?("World Leaders")
- if i!=BATTLE_LIST.index("World Leaders")
- for j in 0...TRAINER_LIST[i].length
- full_list.push(TRAINER_LIST[i][j])
- end
- end
- end
- trainers = []
- loop do
- n = rand(full_list.length)
- trainer = full_list[n]
- full_list.delete_at(n)
- trainers.push(trainer)
- break if trainers.length>7
- end
- TRAINER_LIST[index] = trainers
- end
- # The function used to generate the RentalMasters Tournament trainers
- def generateMixMasters
- return if !BATTLE_LIST.include?("Mix Master")
- index = BATTLE_LIST.index("Mix Master")
- return false if index.nil?
- full_list = []
- for i in 0...index
- next if !BATTLE_LIST.include?("World Leaders") or !BATTLE_LIST.include?("Rental Masters")
- if i!=BATTLE_LIST.index("World Leaders") or i!=BATTLE_LIST.index("Rental Masters")
- for j in 0...TRAINER_LIST[i].length
- full_list.push(TRAINER_LIST[i][j])
- end
- end
- end
- trainers = []
- loop do
- n = rand(full_list.length)
- trainer = full_list[n]
- full_list.delete_at(n)
- trainers.push(trainer)
- break if trainers.length>7
- end
- TRAINER_LIST[index] = trainers
- end
- # Creates a small introductory conversation
- def introduction
- Kernel.pbMessage(_INTL("Hello, and welcome to the Pokemon World Tournament!"))
- Kernel.pbMessage(_INTL("The place where the strongest gather to compete."))
- end
- def announceContest(trainer,i)
- n=rand(4)
- if i==7
- Kernel.pbMessage(_INTL("Announcer: Last but not least, joining us is our very own #{$Trainer.name}!")) if (@player_index==i)
- Kernel.pbMessage(_INTL("Announcer: Last but not least, joining our stadium is #{trainer[1]} from #{trainer[5]}, #{trainer[4]}!")) if !(@player_index==i)
- return true
- end
- case n
- when 0
- Kernel.pbMessage(_INTL("Announcer: Our local youth has talent too, please join me in welcoming #{$Trainer.name}!")) if (@player_index==i)
- Kernel.pbMessage(_INTL("Announcer: Visiting us all the way from #{trainer[5]}, #{trainer[4]}, is #{trainer[1]}!")) if !(@player_index==i)
- when 1
- Kernel.pbMessage(_INTL("Announcer: Spot no. #{i+1} takes a local trainer by the name, #{$Trainer.name}!")) if (@player_index==i)
- Kernel.pbMessage(_INTL("Announcer: Spot no. #{i+1} takes #{trainer[1]} from #{trainer[5]}, #{trainer[4]}!")) if !(@player_index==i)
- when 2
- Kernel.pbMessage(_INTL("Announcer: Our very own aspiring challenger #{$Trainer.name} is here to make a name for themself!")) if (@player_index==i)
- Kernel.pbMessage(_INTL("Announcer: From #{trainer[5]}, #{trainer[4]}, comes the legendary #{trainer[1]}!")) if !(@player_index==i)
- when 3
- Kernel.pbMessage(_INTL("Announcer: The next trainer is #{$Trainer.name} from our very own region!")) if (@player_index==i)
- Kernel.pbMessage(_INTL("Announcer: The next trainer is from #{trainer[5]}, #{trainer[4]}. Please, put your hands together for #{trainer[1]}!")) if !(@player_index==i)
- end
- end
- # Cancels the entry into the Tournament
- def cancelEntry
- self.revertLevels
- Kernel.pbMessage(_INTL("We hope to see you again."))
- return false
- end
- # Saves original Pokemon Levels
- def registerLevels
- @party_levels=[]
- for pokemon in $Trainer.party
- @party_levels.push(pokemon.level)
- end
- @current_party = $Trainer.party.clone
- end
- # Reverts Pokemon levels to original state
- def revertLevels
- $Trainer.party = @current_party
- for i in 0...@party_levels.length
- $Trainer.party[i].level = @party_levels[i]
- $Trainer.party[i].calcStats
- $Trainer.party[i].heal
- end
- end
- # Creates a list of choices depending on the types of battles in BATTLE_LIST
- def chooseTournament
- choices = []
- for i in 0...BATTLE_LIST.index("World Leaders")
- choices.push(BATTLE_LIST[i])
- end
- if ($Trainer.pwt_wins[BATTLE_LIST.index("Kanto Leaders")]>0 &&
- $Trainer.pwt_wins[BATTLE_LIST.index("Johto Leaders")]>0 &&
- $Trainer.pwt_wins[BATTLE_LIST.index("Hoenn Leaders")]>0 &&
- $Trainer.pwt_wins[BATTLE_LIST.index("Sinnoh Leaders")]>0 &&
- $Trainer.pwt_wins[BATTLE_LIST.index("Unova Leaders")]>0)
- choices.push("World Leaders")
- end
- if ($Trainer.pwt_wins[BATTLE_LIST.index("World Champions")]>0)
- choices.push("Rental Masters")
- end
- if ($Trainer.pwt_wins[BATTLE_LIST.index("World Champions")]>0)
- choices.push("Mix Master")
- end
- if ($Trainer.pwt_wins[BATTLE_LIST.index("World Leaders")]>0)
- choices.push("World Champions")
- end
- choices.push("Cancel")
- cmd=Kernel.pbMessage(_INTL("Which Tournament would you like to participate in?"),choices,choices.index("Cancel"))
- return false if choices[cmd]=="Cancel"
- return cmd
- end
- # Allows the player to choose which style of battle they would like to do
- def chooseBattle
- choices = ["Single","Double","Full","Sudden Death","Cancel"]
- cmd=Kernel.pbMessage(_INTL("Which type of Battle would you like to participate in?"),choices,choices.length-1)
- return false if cmd==choices.length-1
- return cmd
- end
- # Checks if the party is eligible
- def partyEligible?
- length = [3,4,6,1][@battle_type]
- count=0
- return false if $Trainer.party.length<length
- for i in 0...$Trainer.party.length
- count+=1 if !(BAN_LIST.include?($Trainer.party[i].species)) && !($Trainer.party[i].egg?)
- end
- return true if count>=length
- return false
- end
- # Creates a new trainer party based on the battle type, and the Pokemon chosen to enter
- def choosePokemon
- ret=false
- return "notEligible" if !partyEligible?
- length = [3,4,6,1][@battle_type]
- Kernel.pbMessage(_INTL("Please choose the Pokemon you would like to participate."))
- ruleset=PokemonRuleSet.new
- ruleset.addPokemonRule(RestrictSpecies.new)
- ruleset.setNumberRange(length,length)
- pbFadeOutIn(99999){
- scene=PokemonScreen_Scene.new
- screen=PokemonScreen.new(scene,$Trainer.party)
- ret=screen.pbPokemonMultipleEntryScreenEx(ruleset)
- }
- return ret
- end
- # Creates the initial trainer list for the first round, depending on the category chosen
- def generateRounds
- for i in 0...@modified_party.length
- @modified_party[i].level=50
- @modified_party[i].calcStats
- end
- @trainer_list = []
- full_list = TRAINER_LIST[@tournament_type].clone
- 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][6]="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 announcerRound1
- 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)
- @sprites["scoreboard"].opacity=255
- 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."))
- @nextTrainer=self.generateRound1
- Kernel.pbMessage(_INTL("Announcer: This will be a battle between #{$Trainer.name} and #{@nextTrainer[1]}."))
- @sprites["scoreboard"].opacity=0
- end
- def announcerRound2
- 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."))
- @nextTrainer=self.generateRound2
- self.createScoreBoard(@trainer_list)
- @sprites["scoreboard"].opacity=255
- Kernel.pbMessage(_INTL("Announcer: It looks like the next match will be between #{$Trainer.name} and #{@nextTrainer[1]}."))
- Kernel.pbMessage(_INTL("Announcer: Let the battle begin!"))
- @sprites["scoreboard"].opacity=0
- end
- def announcerRound3
- 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."))
- @nextTrainer=self.generateRound3
- self.createScoreBoard(@trainer_list)
- @sprites["scoreboard"].opacity=255
- 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 #{@nextTrainer[1]}!"))
- Kernel.pbMessage(_INTL("Announcer: May the best trainer win!"))
- @sprites["scoreboard"].opacity=0
- end
- def winTournament
- 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."))
- end
- def beforeBattleMessage
- outbattleMessage(7)
- end
- def afterBattleWinMessage
- outbattleMessage(8)
- end
- def afterBattleLoseMessage
- outbattleMessage(9)
- end
- def outbattleMessage(listIndex)
- if @nextTrainer[listIndex]
- dialogueLines=@nextTrainer[listIndex].is_a?(Array) ? @nextTrainer[listIndex] : [@nextTrainer[listIndex]]
- for line in dialogueLines
- Kernel.pbMessage(line)
- end
- end
- end
- def battle
- trainerid=@nextTrainer[0]
- trainername=@nextTrainer[1]
- endspeech=@nextTrainer[2]
- endspeechwin=@nextTrainer[3]
- doublebattle=@battle_type==1
- return pbPWTTrainerBattle(trainerid,trainername,endspeech,endspeechwin, doublebattle)
- end
- def setEventGraphic(event)
- filename = @nextTrainer[6]
- begin
- bitmap=BitmapCache.load_bitmap("Graphics/Characters/#{filename}")
- bitmap.dispose
- event.character_name=filename
- rescue
- event.character_name="trchar000"
- end
- 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
- trainer = @trainer_list[[1,0,3,2,5,4,7,6][@player_index]]
- return trainer
- end
- def generateRound2
- healParty
- list=["","","",""]
- @player_index = @player_index/2
- for i in 0...4
- if i == @player_index
- list[i] = @modified_party
- else
- list[i] = @trainer_list[(i*2)+rand(2)]
- end
- end
- @trainer_list=list
- trainer = @trainer_list[[1,0,3,2][@player_index]]
- return trainer
- end
- def generateRound3
- healParty
- list=["","","",""]
- @player_index = @player_index/2
- for i in 0...2
- if i == @player_index
- list[i] = @modified_party
- else
- list[i] = @trainer_list[(i*2)+rand(2)]
- end
- end
- @trainer_list=list
- trainer = @trainer_list[[1,0][@player_index]]
- return trainer
- end
- end
- #===============================================================================
- # PWT battle rules
- #===============================================================================
- class RestrictSpecies
- def initialize
- @specieslist=BAN_LIST.clone
- end
- def isSpecies?(species,specieslist)
- for s in specieslist
- return true if species==s
- end
- return false
- end
- def isValid?(pokemon)
- count=0
- if isSpecies?(pokemon.species,@specieslist) && !(pokemon.egg?)
- count+=1
- end
- return count==0
- end
- end
- #===============================================================================
- # Exta classes and functions for PWT trainer and battle generation
- #===============================================================================
- class PokeBattle_Trainer
- attr_accessor(:battle_points)
- attr_accessor(:pwt_wins)
- end
- # Generates a new PWT styled trainer, where the party is randomized (from the options in the trainer party definition of PBS/trainers.txt)
- def pbPWTLoadTrainer(trainerid,trainername,partyid=0)
- trainer = pbLoadTrainer(trainerid,trainername,partyid)
- return nil if trainer.nil?
- opponent = trainer[0]
- items = trainer[1]
- party = trainer[2]
- length = [3,4,6,1][@battle_type]
- old_party = party.clone
- new_party=[]
- count=0
- loop do
- n=rand(old_party.length)
- new_party.push(old_party[n])
- old_party.delete_at(n)
- break if new_party.length>=length
- end
- party = new_party.clone
- return [opponent,items,party]
- end
- # Creates the PWT styled battle, where exp gain, money gain and switching is disabled
- def pbPWTTrainerBattle(trainerid,trainername,endspeech,endspeechwin,doublebattle=false,trainerparty=0,canlose=true)
- if $Trainer.pokemonCount==0
- Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
- return false
- end
- trainer=pbPWTLoadTrainer(trainerid,trainername,trainerparty)
- if !trainer
- pbMissingTrainer(trainerid,trainername,trainerparty)
- return false
- end
- playerparty=$Trainer.party
- playertrainer=$Trainer
- fullparty1=false
- scene=pbNewBattleScene
- battle=PokeBattle_Battle.new(scene,playerparty,trainer[2],playertrainer,trainer[0])
- battle.fullparty1=fullparty1
- battle.doublebattle=doublebattle
- battle.endspeech=endspeech
- battle.endspeechwin=endspeechwin
- battle.items=trainer[1]
- trainerbgm=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)
- 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
- i.makeUnprimal if INCLUDEGEN6
- end
- }
- Input.update
- return decision
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement