The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Pokemon Contests Script 1.5

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
  #51    
Old December 9th, 2014 (3:20 PM).
p.claydon p.claydon is offline
     
    Join Date: Jan 2011
    Gender: Female
    Posts: 389
    how do u force compile? is it throught the editor.exe?
    __________________
    Still learning how to sprite but if you want to look at my progress then here you go
    http://pclaydon.deviantart.com/gallery/
    Reply With Quote
      #52    
    Old December 9th, 2014 (3:22 PM).
    mej71's Avatar
    mej71 mej71 is offline
       
      Join Date: Mar 2014
      Location: Omnipresence
      Gender: Male
      Posts: 1,222
      Quote:
      Originally Posted by p.claydon View Post
      how do u force compile? is it throught the editor.exe?
      When you're opening the game in Debug mode (pressing F12 in RMXP), hold down Ctrl.
      Reply With Quote
        #53    
      Old December 9th, 2014 (3:26 PM).
      p.claydon p.claydon is offline
         
        Join Date: Jan 2011
        Gender: Female
        Posts: 389
        ok now im getting this error

        Exception: RuntimeError
        Message: Undefined Trainer constant name: 
        Name must consist only of letters, numbers, and
        underscores and can't begin with a number.
        In addition, the name must be defined
        in trainertypes.txt.
        File PBS/trainers.txt, line 1
        

        Compiler:932:in `pbGetConst'
        Compiler:974:in `parseTrainer'
        Compiler:1432:in `pbCompileTrainers'
        Compiler:1430:in `loop'
        Compiler:1532:in `pbCompileTrainers'
        Compiler:4025:in `pbCompileAllData'
        Compiler:4146
        __________________
        Still learning how to sprite but if you want to look at my progress then here you go
        http://pclaydon.deviantart.com/gallery/
        Reply With Quote
          #54    
        Old December 9th, 2014 (3:31 PM).
        mej71's Avatar
        mej71 mej71 is offline
           
          Join Date: Mar 2014
          Location: Omnipresence
          Gender: Male
          Posts: 1,222
          Quote:
          Originally Posted by p.claydon View Post
          ok now im getting this error

          Exception: RuntimeError
          Message: Undefined Trainer constant name: 
          Name must consist only of letters, numbers, and
          underscores and can't begin with a number.
          In addition, the name must be defined
          in trainertypes.txt.
          File PBS/trainers.txt, line 1
          

          Compiler:932:in `pbGetConst'
          Compiler:974:in `parseTrainer'
          Compiler:1432:in `pbCompileTrainers'
          Compiler:1430:in `loop'
          Compiler:1532:in `pbCompileTrainers'
          Compiler:4025:in `pbCompileAllData'
          Compiler:4146
          That has nothing to do with me, you have an error in trainers.txt
          Reply With Quote
            #55    
          Old December 9th, 2014 (3:35 PM). Edited December 9th, 2014 by p.claydon.
          p.claydon p.claydon is offline
             
            Join Date: Jan 2011
            Gender: Female
            Posts: 389
            odd its the default install

            EDIT

            ok used the vs13 pbs files and works now thx for the help tho
            __________________
            Still learning how to sprite but if you want to look at my progress then here you go
            http://pclaydon.deviantart.com/gallery/
            Reply With Quote
              #56    
            Old December 9th, 2014 (3:59 PM).
            ShadowFiendZX's Avatar
            ShadowFiendZX ShadowFiendZX is offline
            Gym Leader
               
              Join Date: Jan 2013
              Location: Hamden Connecticut
              Age: 21
              Gender: Male
              Nature: Serious
              Posts: 59
              Quote:
              Originally Posted by p.claydon View Post
              ok now im getting this error

              Exception: RuntimeError
              Message: Undefined Trainer constant name: 
              Name must consist only of letters, numbers, and
              underscores and can't begin with a number.
              In addition, the name must be defined
              in trainertypes.txt.
              File PBS/trainers.txt, line 1
              

              Compiler:932:in `pbGetConst'
              Compiler:974:in `parseTrainer'
              Compiler:1432:in `pbCompileTrainers'
              Compiler:1430:in `loop'
              Compiler:1532:in `pbCompileTrainers'
              Compiler:4025:in `pbCompileAllData'
              Compiler:4146
              I had the same problem. At first I used his whole code for compiler, and got that error. So I got the original, and made the changes he said to. The logic in his changes in the compiler was somewhat broken, so I had to change a few things. I could give you the code in my compiler if you want, since aside from the changes for the contest, it's clean v14.
              __________________
              BEHOLD THE FLOPPY MAGIKARP IN ALL ITS GLORY AND WISDOM

              Reply With Quote
                #57    
              Old December 9th, 2014 (4:04 PM).
              mej71's Avatar
              mej71 mej71 is offline
                 
                Join Date: Mar 2014
                Location: Omnipresence
                Gender: Male
                Posts: 1,222
                Quote:
                Originally Posted by ShadowFiendZX View Post
                I had the same problem. At first I used his whole code for compiler, and got that error. So I got the original, and made the changes he said to. The logic in his changes in the compiler was somewhat broken, so I had to change a few things. I could give you the code in my compiler if you want, since aside from the changes for the contest, it's clean v14.
                Broken for v14 or in general? I never had a problem with it, so probably something was changed in the compiler.
                Reply With Quote
                  #58    
                Old December 14th, 2014 (7:24 PM).
                CarrEternal CarrEternal is offline
                   
                  Join Date: Jul 2013
                  Gender: Male
                  Posts: 3
                  when i ran a contest, i got this error on the last move of round 4:

                  Exception: RuntimeError
                  Message: Script error within event 5, map 2 (Lappet Town):
                  Exception: NoMethodError
                  Message: Section055:536:in `playTiming'undefined method `pokemon' for 0:Fixnum
                  ***Full script:
                  pbContest(50,PBSpecies::CHARIZARD,20,PBSpecies::SQUIRTLE,20,PBSpecies::HITMONTOP,20,1)

                  Interpreter:243:in `pbExecuteScript'
                  PBAnimation:529:in `each'
                  PBAnimation:529:in `playTiming'
                  PokeContestScene:2763:in `update'
                  PokeContestScene:1968:in `pbAnimationCore'
                  PokeContestScene:1918:in `pbAnimation'
                  PokeContestScene:1914:in `pbSaveShadows'
                  PokeContestScene:1920:in `pbAnimation'
                  PokeContestScene:450:in `pbTurn'
                  PokeContestScene:122:in `pbStartContest'

                  Interpreter:276:in `pbExecuteScript'
                  Interpreter:1600:in `command_355'
                  Interpreter:494:in `execute_command'
                  Interpreter:193:in `update'
                  Interpreter:106:in `loop'
                  Interpreter:198:in `update'
                  Scene_Map:103:in `update'
                  Scene_Map:101:in `loop'
                  Scene_Map:114:in `update'
                  Scene_Map:68:in `main'
                  Reply With Quote
                    #59    
                  Old December 14th, 2014 (8:34 PM). Edited December 15th, 2014 by mej71.
                  mej71's Avatar
                  mej71 mej71 is offline
                     
                    Join Date: Mar 2014
                    Location: Omnipresence
                    Gender: Male
                    Posts: 1,222
                    Quote:
                    Originally Posted by CarrEternal View Post
                    when i ran a contest, i got this error on the last move of round 4:

                    Exception: RuntimeError
                    Message: Script error within event 5, map 2 (Lappet Town):
                    Exception: NoMethodError
                    Message: Section055:536:in `playTiming'undefined method `pokemon' for 0:Fixnum
                    ***Full script:
                    pbContest(50,PBSpecies::CHARIZARD,20,PBSpecies::SQUIRTLE,20,PBSpecies::HITMONTOP,20,1)

                    Interpreter:243:in `pbExecuteScript'
                    PBAnimation:529:in `each'
                    PBAnimation:529:in `playTiming'
                    PokeContestScene:2763:in `update'
                    PokeContestScene:1968:in `pbAnimationCore'
                    PokeContestScene:1918:in `pbAnimation'
                    PokeContestScene:1914:in `pbSaveShadows'
                    PokeContestScene:1920:in `pbAnimation'
                    PokeContestScene:450:in `pbTurn'
                    PokeContestScene:122:in `pbStartContest'

                    Interpreter:276:in `pbExecuteScript'
                    Interpreter:1600:in `command_355'
                    Interpreter:494:in `execute_command'
                    Interpreter:193:in `update'
                    Interpreter:106:in `loop'
                    Interpreter:198:in `update'
                    Scene_Map:103:in `update'
                    Scene_Map:101:in `loop'
                    Scene_Map:114:in `update'
                    Scene_Map:68:in `main'
                    Without me rewriting or adding a lot of things, the best solution right now is to change every instance of pbAnimation(parameters here) to
                    Code:
                    pbAnimation(@currentmove1,nil,1,0)
                    The place where the line is occuring uses user.pokemon , expecting the user part to be an instance of PokemonBattle_Battlers, since I'm just using the animation processes of the battle system. If you use my fix, this shouldn't happen, but it won't play the pokemon's cry when they use a move.

                    As for why it doesn't happen until that turn, I have no idea honestly.

                    This was written for v13 originally, the difference that causes this issue in v14 is the difference between
                    Code:
                    #v14
                    if i.name && i.name!=""
                                  pbSEPlay(i.name,i.volume,i.pitch)
                                else
                                  poke=(user && user.pokemon) ? user.pokemon : 1
                                  name=(pbCryFile(poke) rescue "001Cry")
                                  pbSEPlay(name,i.volume,i.pitch)
                                end
                    and
                    Code:
                    #v13
                    if i.name && i.name!=""
                                  pbSEPlay(i.name,i.volume,i.pitch)
                                else
                                  name=(pbCryFile((user.pokemon rescue 1)) rescue "001Cry")
                                  pbSEPlay(name,i.volume,i.pitch)
                                end
                    Edit: You could revert if you want, but it could cause unexpected consequences, so I'd recommend just using the fix at the top of this post.
                    Reply With Quote
                      #60    
                    Old December 15th, 2014 (3:16 PM).
                    CarrEternal CarrEternal is offline
                       
                      Join Date: Jul 2013
                      Gender: Male
                      Posts: 3
                      Quote:
                      Originally Posted by mej71 View Post
                      Without me rewriting or adding a lot of things, the best solution right now is to change every instance of pbAnimation(parameters here) to
                      Code:
                      pbAnimation(@currentmove1,nil,1,0)
                      The place where the line is occuring uses user.pokemon , expecting the user part to be an instance of PokemonBattle_Battlers, since I'm just using the animation processes of the battle system. If you use my fix, this shouldn't happen, but it won't play the pokemon's cry when they use a move.

                      As for why it doesn't happen until that turn, I have no idea honestly.

                      This was written for v13 originally, the difference that causes this issue in v14 is the difference between
                      Code:
                      #v14
                      if i.name && i.name!=""
                                    pbSEPlay(i.name,i.volume,i.pitch)
                                  else
                                    poke=(user && user.pokemon) ? user.pokemon : 1
                                    name=(pbCryFile(poke) rescue "001Cry")
                                    pbSEPlay(name,i.volume,i.pitch)
                                  end
                      and
                      Code:
                      #v13
                      if i.name && i.name!=""
                                    pbSEPlay(i.name,i.volume,i.pitch)
                                  else
                                    name=(pbCryFile((user.pokemon rescue 1)) rescue "001Cry")
                                    pbSEPlay(name,i.volume,i.pitch)
                                  end
                      You could revert those few lines back to v13 if you want, but I'm not sure what actual advantage the v14 version has.
                      Thank you, its working now.
                      Reply With Quote
                        #61    
                      Old December 15th, 2014 (3:57 PM).
                      Maruno's Avatar
                      Maruno Maruno is offline
                      Lead Dev of Pokémon Essentials
                         
                        Join Date: Jan 2008
                        Location: England
                        Posts: 5,182
                        Wouldn't it be better to make sure this add-on is compatible with Essentials, rather than telling people to change parts of Essentials to make the add-on work?
                        __________________
                        Go to the Essentials Docs Wiki

                        Essentials Docs Wiki

                        Follow me on Twitter: @maruno42


                        Reply With Quote
                          #62    
                        Old December 15th, 2014 (4:14 PM).
                        mej71's Avatar
                        mej71 mej71 is offline
                           
                          Join Date: Mar 2014
                          Location: Omnipresence
                          Gender: Male
                          Posts: 1,222
                          Quote:
                          Originally Posted by Maruno View Post
                          Wouldn't it be better to make sure this add-on is compatible with Essentials, rather than telling people to change parts of Essentials to make the add-on work?
                          I told them what to change in my coding as a temporary fix, it will stop the error. I provided the code difference that was causing it, not really trying to recommend they revert it. I'll edit it to make that more clear though. Fixing this for v14 isn't really a priority at this point though, I've only had about 15 people download it, not really interested into putting more time into this for so few users.
                          Reply With Quote
                            #63    
                          Old December 16th, 2014 (9:40 AM).
                          Derxwna Kapsyla's Avatar
                          Derxwna Kapsyla Derxwna Kapsyla is offline
                          Derxwna "The Badman" Kapsyla
                             
                            Join Date: Jun 2011
                            Location: Margate, FL
                            Age: 25
                            Gender: Male
                            Nature: Lax
                            Posts: 394
                            I intend to make use of the contest scripts once I reach the point in my game where I'll need them, otherwise I don't want to keep reading it every time I update versions and fixing stuff without needing it right away. It's also such a niche thing, that not many people really understand stuff about, and/or have little interest in. That being said, I can't wait to actually make use of the contest scripts, since I find contests fun!
                            __________________
                            Development Blog:
                            For more information future news and updates to any projects, the following blogs are where I post information. You can usually hit me with a message there when it comes to bug reports or feedback, or general conversation about something.
                            Game Projects:
                            In Progress:
                            Reply With Quote
                              #64    
                            Old June 6th, 2015 (7:37 AM). Edited June 6th, 2015 by bimbimthiensu.
                            bimbimthiensu bimbimthiensu is offline
                               
                              Join Date: Jul 2013
                              Gender: Male
                              Posts: 46
                              i have some problem with this, how to fix it?
                              Code:
                              Exception: RuntimeError
                              Message: Script error within event 21, map 92 (Contest Hall):
                              Exception: TypeError
                              Message: Section063:33:in `pos='cannot convert String into Integer
                              ***Full script:
                              pbContest(50,PBSpecies::PIKACHU,20,PBSpecies::CLEFABLE,20,PBSpecies::GRANBULL,20,1)
                              
                              Interpreter:243:in `pbExecuteScript'
                              PBContestMove:33:in `initialize'
                              Main Contest:2004:in `new'
                              Main Contest:2004:in `pbAI'
                              Main Contest:1993:in `each'
                              Main Contest:1993:in `pbAI'
                              Main Contest:201:in `pbTurn'
                              Main Contest:117:in `pbStartContest'
                              Main Contest:2480:in `pbStartContest'
                              Main Contest:2491:in `pbContest'
                              
                              Interpreter:276:in `pbExecuteScript'
                              Interpreter:1606:in `command_355'
                              Interpreter:494:in `execute_command'
                              Interpreter:193:in `update'
                              Interpreter:106:in `loop'
                              Interpreter:198:in `update'
                              Scene_Map:103:in `update'
                              Scene_Map:101:in `loop'
                              Scene_Map:114:in `update'
                              Scene_Map:68:in `main'
                              and other problem
                              Code:
                              Exception: RuntimeError
                              Message: Script error within event 21, map 92 (Contest Hall):
                              Exception: NoMethodError
                              Message: (eval):2:in `pbExecuteScript'undefined method `showSpeciesIntro' for #<Interpreter:0x7afefb0>
                              ***Full script:
                              Kernel.pbMessage(_INTL("First up is Gary's Butterscortch!"))
                              showSpeciesIntro(PBSpecies::CHARIZARD,"","Butterscortch")
                              pbAddContestMove(2,1,2,3,7)
                              pbChangeContestName(2,"Butterscortch")
                              pbContest(50,PBSpecies::CHARIZARD,20,PBSpecies::SQUIRTLE,20,PBSpecies::HITMONTOP,20,1)
                              
                              Interpreter:243:in `pbExecuteScript'
                              Interpreter:1606:in `eval'
                              Interpreter:243:in `pbExecuteScript'
                              Interpreter:1606:in `command_355'
                              Interpreter:494:in `execute_command'
                              Interpreter:193:in `update'
                              Interpreter:106:in `loop'
                              Interpreter:198:in `update'
                              Scene_Map:103:in `update'
                              Scene_Map:101:in `loop'
                              
                              Interpreter:276:in `pbExecuteScript'
                              Interpreter:1606:in `command_355'
                              Interpreter:494:in `execute_command'
                              Interpreter:193:in `update'
                              Interpreter:106:in `loop'
                              Interpreter:198:in `update'
                              Scene_Map:103:in `update'
                              Scene_Map:101:in `loop'
                              Scene_Map:114:in `update'
                              Scene_Map:68:in `main'
                              Reply With Quote
                                #65    
                              Old June 18th, 2015 (7:15 AM). Edited June 20th, 2015 by FoxySeta.
                              FoxySeta's Avatar
                              FoxySeta FoxySeta is offline
                              (Trainer)
                                 
                                Join Date: Sep 2014
                                Location: Lugo (RA) (IT)
                                Gender: Male
                                Nature: Quirky
                                Posts: 11
                                Well I'm using Pokémon Essentials 15.1.
                                I only didn't changed def "Kernel.pbMessageDisplay" (because I also would like to edit it for Caramaniac's Speech Buble pack, so I have to mix them) and I renamed variables 35 and 36.
                                It says there's a syntax error here, in line 757 of PItem_ItemEffects:
                                Quote:
                                pokemon.cool=255 if pokemon.cool>255 pokemon.sheen+=17
                                I guess there're also syntax errors for other PokéBlock, but I don't know RGSS at all.
                                Reply With Quote
                                  #66    
                                Old June 20th, 2015 (8:38 AM). Edited June 20th, 2015 by Zeak6464.
                                Zeak6464's Avatar
                                Zeak6464 Zeak6464 is offline
                                Zeak #3205 - Discord
                                   
                                  Join Date: Mar 2013
                                  Location: USA
                                  Age: 25
                                  Gender: Male
                                  Nature: Calm
                                  Posts: 550
                                  This works for Essentials 15.1 , but the issue i ran into is the "Contest" script needs updated.. which is here
                                  also make sure you copy the "Contest Map" !
                                  1: Make sure you read the 1st post !
                                  2: Enter Each Script Manually
                                  3: Make sure you have all the GFX & PBS




                                  Hoenn is going to love this :)
                                  Spoiler:

                                  class PokeContestScene
                                  attr_reader :name
                                  attr_accessor :selected
                                  attr_reader :hearts


                                  def initialize
                                  @sprites={}
                                  @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                                  @viewport.z=99999
                                  @viewport2=Viewport.new(0,0,Graphics.width,Graphics.height)
                                  @viewport2.z=99999+2
                                  @sprites["background"]=IconSprite.new(0,0,@viewport)
                                  @sprites["background"].setBitmap("Graphics/Pictures/Contest/contestbg")
                                  end

                                  #CONTESTCOMBOS are defined in the bottom of this script
                                  def pbCheckforCombos
                                  case @currentpoke
                                  when @pkmn1
                                  [email protected]
                                  when @pkmn2
                                  [email protected]
                                  when @pkmn3
                                  [email protected]
                                  when @pkmn4
                                  [email protected]
                                  end
                                  for j in 0..CONTESTCOMBOS.length-1
                                  if oldmove==CONTESTCOMBOS[j][0]
                                  for i in 1..CONTESTCOMBOS[j].length-1
                                  if @currentmovename==CONTESTCOMBOS[j][i]
                                  return true
                                  end
                                  end
                                  end
                                  end
                                  return false
                                  end

                                  def update
                                  pbUpdateSpriteHash(@sprites)
                                  end

                                  def pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
                                  pbBGMPlay("021-Field04") #Change this for different music
                                  @contestover=false #ends when set to true
                                  @difficulty=difficulty
                                  @ribbonnum=ribbonnum #ribbon number given if won
                                  case $game_variables[35]
                                  when 1
                                  @contestType="Cool"
                                  when 2
                                  @contestType="Beauty"
                                  when 3
                                  @contestType="Cute"
                                  when 4
                                  @contestType="Smart"
                                  when 5
                                  @contestType="Tough"
                                  else
                                  @contestType="Cool"
                                  end
                                  @pkmn1=$Trainer.party[$game_variables[36]]
                                  @pkmn2=PokeBattle_Pokemon.new(opponent1,opponent1level,$Trainer)
                                  @pkmn3=PokeBattle_Pokemon.new(opponent2,opponent2level,$Trainer)
                                  @pkmn4=PokeBattle_Pokemon.new(opponent3,opponent3level,$Trainer)
                                  #teach opponent pokemon new moves if defined
                                  for i in 0...CONTESTMOVE2.length
                                  @pkmn2.pbLearnMove(CONTESTMOVE2[i]) if CONTESTMOVE2[i]!=0
                                  end
                                  for i in 0...CONTESTMOVE3.length
                                  @pkmn3.pbLearnMove(CONTESTMOVE3[i]) if CONTESTMOVE3[i]!=0
                                  end
                                  for i in 0...CONTESTMOVE4.length
                                  @pkmn4.pbLearnMove(CONTESTMOVE4[i]) if CONTESTMOVE4[i]!=0
                                  end
                                  #nicknames for contest pokemon
                                  @pkmn2.name=$CONTESTNAME2 if $CONTESTNAME2 !=""
                                  @pkmn3.name=$CONTESTNAME3 if $CONTESTNAME3 !=""
                                  @pkmn4.name=$CONTESTNAME4 if $CONTESTNAME4 !=""
                                  @pkmn1total=0
                                  @pkmn2total=0
                                  @pkmn3total=0
                                  @pkmn4total=0
                                  @pkmn1DoubleNext=false
                                  @pkmn2DoubleNext=false
                                  @pkmn3DoubleNext=false
                                  @pkmn4DoubleNext=false
                                  @pkmn1MissTurn=false
                                  @pkmn2MissTurn=false
                                  @pkmn3MissTurn=false
                                  @pkmn4MissTurn=false
                                  @pkmn1nomoremoves=false
                                  @pkmn2nomoremoves=false
                                  @pkmn3nomoremoves=false
                                  @pkmn4nomoremoves=false
                                  @applause=0
                                  @pkmn1stars=0
                                  @pkmn2stars=0
                                  @pkmn3stars=0
                                  @pkmn4stars=0
                                  @pkmn1hearts=0
                                  @pkmn2hearts=0
                                  @pkmn3hearts=0
                                  @pkmn4hearts=0
                                  @stars=[@pkmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
                                  pbPreliminaryScene #extra points for scarves, points gained by pokeblocks and such done here
                                  #the "preliminary judging" seen before this starts is just for show, it doesn't do anything then
                                  pbResetContestMoveEffects
                                  pbResetHearts
                                  @round=0
                                  if !($DEBUG && Input.press?(Input::CTRL)) #Skip all rounds if pressing Control in Debug mode
                                  @round=1
                                  pbTurn(@round)
                                  if !($DEBUG && Input.press?(Input::CTRL))
                                  @round=2
                                  pbTurn(@round)
                                  @round=3
                                  pbTurn(@round)
                                  @round=4
                                  pbTurn(@round)
                                  @round=5
                                  pbTurn(@round)
                                  else
                                  pbResetHearts
                                  pbDebugTotals(1)
                                  end
                                  else
                                  @prelim1+=90
                                  pbResetHearts
                                  pbDebugTotals(6)
                                  end
                                  pbDisposeSprite(@sprites,"overlay2") #clear overlay to prep for end scene
                                  # End scene
                                  @sprites["background"]=IconSprite.new(0,0,@viewport)
                                  @sprites["background"].setBitmap("Graphics/Pictures/Contest/contestbg")
                                  pbResultsScene
                                  $game_variables[35]=0 #reset variables
                                  $game_variables[36]=0
                                  @contestover=true #allows scene to exit loop and end
                                  end

                                  ###############################################################################
                                  # Main round processing function
                                  ###############################################################################
                                  def pbTurn(turnnumber)
                                  Graphics.update
                                  @atself=false
                                  @priorhearts=0
                                  if @round==1
                                  @sprites["Judge"]=IconSprite.new(0,0,@viewport)
                                  @sprites["Judge"].setBitmap("Graphics/Characters/trainer017")
                                  Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Welcome to today's {1} Type Pokemon Contest\nIt's heartwarming to see all these young trainers here to show off their Pokemon's skills!",@contestType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  Kernel.pbCustomMessage(_INTL("\\l[3]\\c[1]I'm going to be the judge for this competition, so let's get started!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisposeSprite(@sprites,"Judge")
                                  sleep(1.0/3.0)
                                  Graphics.update
                                  end
                                  if @round==1 #
                                  pbFindFastestOrderRanking #
                                  else #determine order
                                  pbOrder #
                                  end #
                                  pbResetContestMoveEffects
                                  pbDrawText
                                  roundfile=(turnnumber==1)? "Graphics/Pictures/Contest/Roundone":(turnnumber==2)?"Graphics/Pictures/Contest/Roundtwo":(turnnumber==3)?"Graphics/Pictures/Contest/Roundthree":(turnnumber==4)?"Graphics/Pictures/Contest/Roundfour":"Graphics/Pictures/Contest/Roundfive"
                                  @sprites["Round"]=IconSprite.new(0,0,@viewport)
                                  @sprites["Round"].setBitmap(roundfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  roundupdown=0
                                  for i in 0...9
                                  if roundupdown==0 or roundupdown==1 or roundupdown==4 or roundupdown==5 or roundupdown==8 or roundupdown==9
                                  @sprites["Round"].y+=6
                                  else
                                  @sprites["Round"].y-=6
                                  end
                                  roundupdown+=1
                                  Graphics.update
                                  sleep(1.0/7.0)
                                  end
                                  sleep(1)
                                  pbDisposeSprite(@sprites,"Round")
                                  pbMoveButtons
                                  @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                                  pbSetSystemFont(@sprites["overlay"].bitmap)
                                  pbDisplayFastest
                                  @sprites["opponent"]=IconSprite.new(50,30,@viewport) #
                                  @sprites["opponent"].setBitmap("Graphics/Battler/000") #invisible sprite to serve as target for animations
                                  @sprites["opponent"].visible=false #
                                  Graphics.update
                                  Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Alright {1}, let's see what you can do!",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @currentpos=1
                                  @[email protected][0]
                                  if @[email protected] #
                                  [email protected] #
                                  else #Determine which move to use
                                  i=pbAI(@pokeorder[0],@difficulty) # AI for opponents
                                  end #
                                  movedata=PBMoveData.new(@pokeorder[0].moves[i].id)
                                  @currentmovename=PBMoves.getName(@pokeorder[0].moves[i].id)
                                  sleep(1)
                                  for i in 1..PBContestMoves.maxValue #
                                  name=PBContestMoves.getName(i) #
                                  if @currentmovename==name # Match the pokemon's move with the equivalent from contestmoves.txt
                                  @currentmove=getID(PBContestMoves,i) #
                                  @currentmove1=getID(PBMoves,i) # Get actual ID to display proper move animation
                                  end
                                  end
                                  (movedata.target==PBTargets::User)? @atself=true :@atself=false
                                  contestmovedata=PBContestMoveData.new(@currentmove) #Find the moves contest data
                                  @currenthearts=contestmovedata.hearts
                                  moveType=contestmovedata.contestType
                                  pbmoveType(moveType)
                                  if pbNoMore==false #skip the move processing if nomore moves is true
                                  if pbMissTurn==false #skip move processing if it misses this turn
                                  if pbDoubleNext==true #check for double hearts
                                  @currenthearts*=2
                                  pbReverseDoubleNext
                                  end
                                  if @nervous[@currentpos-1]==true
                                  Kernel.pbCustomMessage(_INTL("\\\l[3]{1} is nervous.",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  if rand(100)<30 #check for nervousness, 30% chance
                                  Kernel.pbCustomMessage(_INTL("\\\l[3]{1} was too nervous to move!",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[0].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[0].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  pbReverseMissTurn #change miss turn variable back after missing turn
                                  end
                                  end
                                  pbFunctionsAdjustHearts #
                                  pbDisplayAddingPositiveHearts
                                  if pbCheckLast && @currentfunction !=15 && @round !=1
                                  @currenthearts-=1
                                  Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
                                  pbDecreaseHearts(@currentpoke,@currentpos,selfjam="notnil")
                                  end
                                  if @round !=1 && pbCheckforCombos==true
                                  @currenthearts=5
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisplayAddingPositiveHearts
                                  pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
                                  end
                                  pbAssignLastMove
                                  @[email protected]
                                  pbCrowd
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Good job {1}, now onto the next pokemon!",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  sleep(1.0/10.0)
                                  pbDisposeSprite(@sprites,"pokemon1")
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisplaySecondFastest
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  @currentpos=2
                                  @[email protected][1]
                                  if @[email protected]
                                  [email protected]
                                  else
                                  i=pbAI(@pokeorder[1],@difficulty)
                                  end
                                  movedata=PBMoveData.new(@pokeorder[1].moves[i].id)
                                  @currentmovename=PBMoves.getName(@pokeorder[1].moves[i].id)
                                  sleep(1)
                                  for i in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(i)
                                  if @currentmovename==name
                                  @currentmove=getID(PBContestMoves,i)
                                  @currentmove1=getID(PBMoves,i)
                                  end
                                  end
                                  (movedata.target==PBTargets::User)? @atself=true :@atself=false
                                  contestmovedata=PBContestMoveData.new(@currentmove)
                                  @currenthearts=contestmovedata.hearts
                                  moveType=contestmovedata.contestType
                                  pbmoveType(moveType)
                                  if pbNoMore==false #skip the move processing if nomore moves is true
                                  if pbMissTurn==false #skip move processing if it misses this turn
                                  if pbDoubleNext==true #check for double hearts
                                  @currenthearts*=2
                                  pbReverseDoubleNext
                                  end
                                  if @nervous[@currentpos-1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  if rand(100)<30 #check for nervousness, 30% chance
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[1].name))
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[1].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[1].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  pbReverseMissTurn #change miss turn variable back after missing turn
                                  end
                                  end
                                  pbFunctionsAdjustHearts
                                  pbDisplayAddingPositiveHearts
                                  if pbCheckLast && @currentfunction !=15 && @round !=1
                                  @currenthearts-=1
                                  Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
                                  pbDecreaseHearts(@currentpoke,@currentpos,selfjam="notnil")
                                  end
                                  if @round !=1 && pbCheckforCombos==true
                                  @currenthearts=5
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisplayAddingPositiveHearts
                                  pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
                                  end
                                  pbAssignLastMove
                                  @[email protected]
                                  pbCrowd
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  pbDisposeSprite(@sprites,"pokemon2")
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisplayThirdFastest
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  @currentpos=3
                                  @[email protected][2]
                                  if @[email protected]
                                  [email protected]
                                  else
                                  i=pbAI(@pokeorder[2],@difficulty)
                                  end
                                  movedata=PBMoveData.new(@pokeorder[2].moves[i].id)
                                  @currentmovename=PBMoves.getName(@pokeorder[2].moves[i].id)
                                  sleep(1)
                                  for i in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(i)
                                  if @currentmovename==name
                                  @currentmove=getID(PBContestMoves,i)
                                  @currentmove1=getID(PBMoves,i)
                                  end
                                  end
                                  (movedata.target==PBTargets::User)? @atself=true :@atself=false
                                  contestmovedata=PBContestMoveData.new(@currentmove)
                                  @currenthearts=contestmovedata.hearts
                                  moveType=contestmovedata.contestType
                                  pbmoveType(moveType)
                                  if pbNoMore==false #skip the move processing if nomore moves is true
                                  if pbMissTurn==false #skip move processing if it misses this turn
                                  if pbDoubleNext==true #check for double hearts
                                  @currenthearts*=2
                                  pbReverseDoubleNext
                                  end
                                  if @nervous[@currentpos-1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  if rand(100)<30 #check for nervousness, 30% chance
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[2].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[2].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  pbReverseMissTurn #change miss turn variable back after missing turn
                                  end
                                  end
                                  pbFunctionsAdjustHearts #
                                  pbDisplayAddingPositiveHearts
                                  if pbCheckLast && @currentfunction !=15 && @round !=1
                                  @currenthearts-=1
                                  Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
                                  pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,selfjam="notnil")
                                  end
                                  if @round !=1 && pbCheckforCombos==true
                                  @currenthearts=5
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisplayAddingPositiveHearts
                                  pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
                                  end
                                  pbAssignLastMove
                                  @[email protected]
                                  pbCrowd
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  pbDisposeSprite(@sprites,"pokemon3")
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisplayFourthFastest
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  @currentpos=4
                                  @[email protected][3]
                                  if @[email protected]
                                  [email protected]
                                  else
                                  i=pbAI(@pokeorder[3],@difficulty)
                                  end
                                  movedata=PBMoveData.new(@pokeorder[3].moves[i].id)
                                  @currentmovename=PBMoves.getName(@pokeorder[3].moves[i].id)
                                  sleep(1)
                                  for i in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(i)
                                  if @currentmovename==name
                                  @currentmove=getID(PBContestMoves,i)
                                  @currentmove1=getID(PBMoves,i)
                                  end
                                  end
                                  (movedata.target==PBTargets::User)? @atself=true :@atself=false
                                  contestmovedata=PBContestMoveData.new(@currentmove)
                                  @currenthearts=contestmovedata.hearts
                                  moveType=contestmovedata.contestType
                                  pbmoveType(moveType)
                                  if pbNoMore==false #skip the move processing if nomore moves is true
                                  if pbMissTurn==false #skip move processing if it misses this turn
                                  if pbDoubleNext==true #check for double hearts
                                  @currenthearts*=2
                                  pbReverseDoubleNext
                                  end
                                  if @nervous[@currentpos-1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  if rand(100)<30 #check for nervousness, 30% chance
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[3].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[3].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbAnimation(@currentmove1,0,1,hitnum=0)
                                  end
                                  else
                                  pbReverseMissTurn #change miss turn variable back after missing turn
                                  end
                                  end
                                  pbFunctionsAdjustHearts #
                                  pbDisplayAddingPositiveHearts
                                  if pbCheckLast && @currentfunction !=15 && @round !=1
                                  @currenthearts-=1
                                  Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
                                  pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,selfjam="notnil")
                                  end
                                  if @round !=1 && pbCheckforCombos==true
                                  @currenthearts=5
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  pbDisplayAddingPositiveHearts
                                  pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
                                  end
                                  pbAssignLastMove
                                  @[email protected]
                                  pbCrowd
                                  Graphics.update
                                  sleep(1.0/10.0)
                                  pbDisposeSprite(@sprites,"pokemon4")
                                  pbDisposeSprite(@sprites,"opponent")
                                  pbResetHearts
                                  Graphics.update
                                  end

                                  ###############################################################################
                                  # Misc. Functions
                                  ###############################################################################
                                  def pbAssignLastMove
                                  case @currentpoke
                                  when @pkmn1
                                  @[email protected]
                                  when @pkmn2
                                  @[email protected]
                                  when @pkmn3
                                  @[email protected]
                                  else
                                  @[email protected]
                                  end
                                  end

                                  def pbCheckLast
                                  case @currentpoke
                                  when @pkmn1
                                  if @pkmn1lastmove
                                  if @[email protected]
                                  return true
                                  else
                                  return false
                                  end
                                  end
                                  when @pkmn2
                                  if @pkmn2lastmove
                                  if @[email protected]
                                  return true
                                  else
                                  return false
                                  end
                                  end
                                  when @pkmn3
                                  if @pkmn3lastmove
                                  if @[email protected]
                                  return true
                                  else
                                  return false
                                  end
                                  end
                                  when @pkmn4
                                  if @pkmn4lastmove
                                  if @[email protected]
                                  return true
                                  else
                                  return false
                                  end
                                  end
                                  end
                                  end

                                  def pbmoveType(moveType)
                                  case moveType
                                  when 0
                                  @moveType="Cool"
                                  when 1
                                  @moveType="Beauty"
                                  when 2
                                  @moveType="Cute"
                                  when 3
                                  @moveType="Smart"
                                  when 4
                                  @moveType="Tough"
                                  end
                                  end

                                  def pbDrawText
                                  @sprites["overlay2"].bitmap.clear if @sprites["overlay2"]
                                  #change graphic indicating what position the player's pokemon is at
                                  if [email protected]["playerspokebg"]
                                  @sprites["playerspokebg"]=IconSprite.new(347,96,@viewport)
                                  @sprites["playerspokebg"].setBitmap("Graphics/Pictures/Contest/playerspoke")
                                  end
                                  for i in 0..3
                                  if @pokeorder[i][email protected]
                                  @sprites["playerspokebg"].y=96*i
                                  end
                                  end
                                  @sprites["overlay2"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport) if [email protected]["overlay2"]
                                  pbSetSystemFont(@sprites["overlay2"].bitmap)
                                  [email protected]["overlay2"].bitmap
                                  overlay.clear
                                  pokeone=_INTL("{1}",@pokeorder[0].name)
                                  poketwo=_INTL("{1}",@pokeorder[1].name)
                                  pokethree=_INTL("{1}",@pokeorder[2].name)
                                  pokefour=_INTL("{1}",@pokeorder[3].name)
                                  baseColor=Color.new(72,72,72)
                                  shadowColor=Color.new(160,160,160)
                                  textPositions=[
                                  [pokeone,353,5,false,baseColor,shadowColor],
                                  [poketwo,353,100,false,baseColor,shadowColor],
                                  [pokethree,353,195,false,baseColor,shadowColor],
                                  [pokefour,353,290,false,baseColor,shadowColor],
                                  ]
                                  pbDrawTextPositions(overlay,textPositions)
                                  end


                                  def pbNoMore #checks if pokemon can use moves
                                  case @currentpoke
                                  when @pkmn1
                                  if @pkmn1nomoremoves==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn2
                                  if @pkmn2nomoremoves==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn3
                                  if @pkmn3nomoremoves==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn4
                                  if @pkmn4nomoremoves==true
                                  return true
                                  else
                                  return false
                                  end
                                  else
                                  return false
                                  end
                                  end

                                  def pbMissTurn #Checks if pokemon misses this turn
                                  case @currentpoke
                                  when @pkmn1
                                  if @pkmn1MissTurn==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn2
                                  if @pkmn2MissTurn==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn3
                                  if @pkmn3MissTurn==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn4
                                  if @pkmn4MissTurn==true
                                  return true
                                  else
                                  return false
                                  end
                                  else
                                  return false
                                  end
                                  end

                                  def pbDoubleNext #Check if it should double hearts
                                  case @currentpoke
                                  when @pkmn1
                                  if @pkmn1DoubleNext==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn2
                                  if @pkmn2DoubleNext==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn3
                                  if @pkmn3DoubleNext==true
                                  return true
                                  else
                                  return false
                                  end
                                  when @pkmn4
                                  if @pkmn4DoubleNext==true
                                  return true
                                  else
                                  return false
                                  end
                                  else
                                  return false
                                  end
                                  end

                                  def pbSetNoMoreMoves
                                  case @currentpoke
                                  when @pkmn1
                                  @pkmn1nomoremoves=true
                                  when @pkmn2
                                  @pkmn2nomoremoves=true
                                  when @pkmn3
                                  @pkmn3nomoremoves=true
                                  when @pkmn4
                                  @pkmn4nomoremoves=true
                                  end
                                  end

                                  def pbSetMissTurn
                                  case @currentpoke
                                  when @pkmn1
                                  @pkmn1MissTurn=true
                                  when @pkmn2
                                  @pkmn2MissTurn=true
                                  when @pkmn3
                                  @pkmn3MissTurn=true
                                  when @pkmn4
                                  @pkmn4MissTurn=true
                                  end
                                  end

                                  def pbSetDoubleNext
                                  case @currentpoke
                                  when @pkmn1
                                  @pkmn1DoubleNext=true
                                  when @pkmn2
                                  @pkmn2DoubleNext=true
                                  when @pkmn3
                                  @pkmn3DoubleNext=true
                                  when @pkmn4
                                  @pkmn4DoubleNext=true
                                  end
                                  end

                                  def pbReverseMissTurn
                                  case @currentpoke
                                  when @pkmn1
                                  @pkmn1MissTurn=false
                                  when @pkmn2
                                  @pkmn2MissTurn=false
                                  when @pkmn3
                                  @pkmn3MissTurn=false
                                  when @pkmn4
                                  @pkmn4MissTurn=false
                                  end
                                  end

                                  def pbReverseDoubleNext
                                  case @currentpoke
                                  when @pkmn1
                                  @pkmn1DoubleNext=false
                                  when @pkmn2
                                  @pkmn2DoubleNext=false
                                  when @pkmn3
                                  @pkmn3DoubleNext=false
                                  when @pkmn4
                                  @pkmn4DoubleNext=false
                                  end
                                  end



                                  ###############################################################################
                                  # Heart Graphic Functions
                                  ###############################################################################
                                  def pbDisplayAddingPositiveHearts
                                  case @currentpoke
                                  when @pkmn1
                                  for i in [email protected]
                                  @pkmn1hearts+=1
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn1hearts)if @pkmn1hearts<21
                                  Graphics.update
                                  sleep(1.0/7.0)
                                  @sprites["firstpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
                                  @sprites["firstpokehearts"].setBitmap(heartfile)
                                  end
                                  @[email protected]
                                  when @pkmn2
                                  for i in [email protected]
                                  @pkmn2hearts+=1
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn2hearts)if @pkmn2hearts<21
                                  Graphics.update
                                  sleep(1.0/7.0)
                                  @sprites["secondpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
                                  @sprites["secondpokehearts"].setBitmap(heartfile)
                                  end
                                  @[email protected]
                                  when @pkmn3
                                  for i in [email protected]
                                  @pkmn3hearts+=1
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn3hearts)if @pkmn3hearts<21
                                  Graphics.update
                                  sleep(1.0/7.0)
                                  @sprites["thirdpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
                                  @sprites["thirdpokehearts"].setBitmap(heartfile)
                                  end
                                  @[email protected]
                                  when @pkmn4
                                  for i in [email protected]
                                  @pkmn4hearts+=1
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn4hearts)if @pkmn4hearts<21
                                  Graphics.update
                                  sleep(1.0/7.0)
                                  @sprites["fourthpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
                                  @sprites["fourthpokehearts"].setBitmap(heartfile)
                                  end
                                  @[email protected]
                                  end
                                  end

                                  def pbDecreaseHearts(target,position,selfjam=nil)
                                  if selfjam==nil
                                  if @currentjam==1
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} looked down out of distraction!",target.name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} couldn't help leaping up!",target.name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  end
                                  end
                                  case target
                                  when @pkmn1
                                  @pkmn1jam*=2 if @easilystartled[position-1]==true
                                  for i in [email protected]
                                  @pkmn1hearts -= 1
                                  if @pkmn1hearts == 0
                                  pbDisposeSprite(@sprites,"firstpokehearts")
                                  @sprites["firstpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
                                  end
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn1hearts) if @pkmn1hearts >= 0 && @pkmn1hearts<21
                                  heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn1hearts.abs) if @pkmn1hearts < 0 && @pkmn1hearts>-21
                                  @sprites["firstpokehearts"].setBitmap(heartfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  end
                                  @[email protected]
                                  when @pkmn2
                                  @pkmn2jam*=2 if @easilystartled[position-1]==true
                                  for i in [email protected]
                                  @pkmn2hearts -= 1
                                  if @pkmn2hearts == 0
                                  pbDisposeSprite(@sprites,"secondpokehearts")
                                  @sprites["secondpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
                                  end
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn2hearts) if @pkmn2hearts >= 0 && @pkmn2hearts<21
                                  heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn2hearts.abs) if @pkmn2hearts < 0 && @pkmn2hearts>-21
                                  @sprites["secondpokehearts"].setBitmap(heartfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  end
                                  @[email protected]
                                  when @pkmn3
                                  @pkmn3jam*=2 if @easilystartled[position-1]==true
                                  for i in [email protected]
                                  @pkmn3hearts -= 1
                                  if @pkmn3hearts == 0
                                  pbDisposeSprite(@sprites,"thirdpokehearts")
                                  @sprites["thirdpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
                                  end
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn3hearts) if @pkmn3hearts >= 0 && @pkmn3hearts<21
                                  heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn3hearts.abs) if @pkmn3hearts < 0 && @pkmn3hearts>-21
                                  @sprites["thirdpokehearts"].setBitmap(heartfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  end
                                  @[email protected]
                                  when @pkmn4
                                  @pkmn4jam*=2 if @easilystartled[position-1]==true
                                  for i in [email protected]
                                  @pkmn4hearts -= 1
                                  if @pkmn4hearts == 0
                                  pbDisposeSprite(@sprites,"fourthpokehearts")
                                  @sprites["fourthpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
                                  end
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn4hearts) if @pkmn4hearts >= 0 && @pkmn4hearts<21
                                  heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn4hearts.abs) if @pkmn4hearts < 0 && @pkmn4hearts>-21
                                  @sprites["fourthpokehearts"].setBitmap(heartfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  end
                                  @[email protected]
                                  end
                                  end
                                  ###############################################################################
                                  # Get rid of hearts graphics at end round, and add up heart totals
                                  ###############################################################################
                                  def pbResetHearts
                                  pbDisposeSprite(@sprites,"firstpokehearts")
                                  pbDisposeSprite(@sprites,"secondpokehearts")
                                  pbDisposeSprite(@sprites,"thirdpokehearts")
                                  pbDisposeSprite(@sprites,"fourthpokehearts")
                                  @[email protected]
                                  @[email protected]
                                  @[email protected]
                                  @[email protected]
                                  @roundonetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==1
                                  @roundtwototals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==2
                                  @roundthreetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==3
                                  @roundfourtotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==4
                                  @roundfivetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==5
                                  @pkmn1hearts=0
                                  @pkmn2hearts=0
                                  @pkmn3hearts=0
                                  @pkmn4hearts=0
                                  Graphics.update
                                  sleep(1/2)
                                  end

                                  def pbDebugTotals(round) #random assortment of numbers, ensuring your pokemon wins. Intended to be used in debugging the end scene
                                  @roundonetotals=[20,rand(10),rand(10),rand(10)] if round>0
                                  @roundtwototals=[20,rand(10),rand(10),rand(10)]
                                  @roundthreetotals=[20,rand(10),rand(10),rand(10)]
                                  @roundfourtotals=[20,rand(10),rand(10),rand(10)]
                                  @roundfivetotals=[20,rand(10),rand(10),rand(10)]
                                  @pkmn1total=(@roundonetotals[0][email protected][0][email protected][0][email protected][0][email protected][0])
                                  @pkmn2total=(@roundonetotals[1][email protected][1][email protected][1][email protected][1][email protected][1])
                                  @pkmn3total=(@roundonetotals[2][email protected][2][email protected][2][email protected][2][email protected][2])
                                  @pkmn4total=(@roundonetotals[3][email protected][3][email protected][3][email protected][3][email protected][3])

                                  end
                                  ###############################################################################
                                  # Determines order for first round, goes by base speed
                                  ###############################################################################
                                  def pbFindFastestOrderRanking #Finds the fastest pokemon in the contest
                                  dexdata=pbOpenDexData
                                  pbDexDataOffset(dexdata,@pkmn1.species,13)
                                  basespeed1=dexdata.fgetb
                                  pokespeed1=basespeed1
                                  pbDexDataOffset(dexdata,@pkmn2.species,13)
                                  basespeed2=dexdata.fgetb
                                  pokespeed2=basespeed2
                                  pbDexDataOffset(dexdata,@pkmn3.species,13)
                                  basespeed3=dexdata.fgetb
                                  pokespeed3=basespeed3
                                  pbDexDataOffset(dexdata,@pkmn4.species,13)
                                  basespeed4=dexdata.fgetb
                                  pokespeed4=basespeed4
                                  dexdata.close
                                  fastest = [basespeed1, basespeed2, basespeed3, basespeed4]
                                  fastest=fastest.sort.reverse
                                  neworder=[]
                                  first=(fastest[0]==pokespeed1)? @pkmn1 : ((fastest[0]==pokespeed2) ? @pkmn2 : ((fastest[0]==pokespeed3)? @pkmn3 : @pkmn4))
                                  neworder.push(first)
                                  second =(fastest[1]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[1]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[1]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
                                  neworder.push(second)
                                  third =(fastest[2]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[2]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[2]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
                                  neworder.push(third)
                                  fourth=(fastest[3]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[3]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[3]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
                                  neworder.push(fourth)
                                  @pokeorder=neworder
                                  end

                                  ###############################################################################
                                  # Determine order for next round
                                  ###############################################################################
                                  def pbOrder
                                  order=[]
                                  @stars=[]
                                  mosthearts=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total].sort.reverse
                                  if @MoveUp.include?(true)
                                  for i in [email protected]
                                  if @MoveUp[i]==true && @MoveDown[i]==false
                                  newpoke=(@pokeorder[i][email protected])? @pkmn1:(@pokeorder[i][email protected])? @pkmn2:(@pokeorder[i][email protected])? @pkmn3:@pkmn4
                                  order.push(newpoke)
                                  newstars=([email protected])? @pkmn1stars:([email protected])? @pkmn2stars:([email protected])? @pkmn3stars:@pkmn4stars
                                  @stars.push(newstars)
                                  end
                                  end
                                  end
                                  if order.length<4
                                  for i in [email protected]
                                  newpoke=nil
                                  if (mosthearts[i][email protected] && !(order.include?(@pkmn1)) && @MoveDown[pbCurrentPokeNum2(@pkmn1)]==false)
                                  [email protected]
                                  elsif (mosthearts[i][email protected] && !(order.include?(@pkmn2)) && @MoveDown[pbCurrentPokeNum2(@pkmn2)]==false)
                                  [email protected]
                                  elsif (mosthearts[i][email protected] && !(order.include?(@pkmn3)) && @MoveDown[pbCurrentPokeNum2(@pkmn3)]==false)
                                  [email protected]
                                  elsif (mosthearts[i][email protected] && !(order.include?(@pkmn4)) && @MoveDown[pbCurrentPokeNum2(@pkmn4)]==false)
                                  [email protected]
                                  end
                                  if newpoke !=nil
                                  order.push(newpoke)
                                  newstars=([email protected])? @pkmn1stars:([email protected])? @pkmn2stars:([email protected])? @pkmn3stars:@pkmn4stars
                                  @stars.push(newstars)
                                  end
                                  end
                                  end
                                  if @MoveDown.include?(true)
                                  for i in [email protected]
                                  if @MoveDown[i]==true && @MoveUp[i]==false
                                  newpoke=(@pokeorder[i][email protected])? @pkmn1:(@pokeorder[i][email protected])? @pkmn2:(@pokeorder[i][email protected])? @pkmn3:@pkmn4
                                  order.push(newpoke)
                                  newstars=([email protected])? @pkmn1stars:([email protected])? @pkmn2stars:([email protected])? @pkmn3stars:@pkmn4stars
                                  @stars.push(newstars)
                                  end
                                  end
                                  end
                                  if @Scramble==true #random order for Scramble
                                  Kernel.srand
                                  order.shuffle
                                  Kernel.srand
                                  @stars.shuffle
                                  end
                                  @pokeorder.clear
                                  @pokeorder=order
                                  end

                                  ###############################################################################
                                  # Display Pokemon Graphics
                                  ###############################################################################
                                  def pbDisplayFastest #Displays the sprite of the fastest pokemon, as per FindFastest
                                  @sprites["pokemon1"]=PokemonSprite.new(@viewport)
                                  @sprites["pokemon1"].setPokemonBitmap(@pokeorder[0],true)
                                  @sprites["pokemon1"].mirror=true
                                  pokemony=Graphics.height/2-32
                                  pokemonyadjust=pokemony-32
                                  pbPositionPokemonSprite(@sprites["pokemon1"],178,112)
                                  end
                                  def pbDisplaySecondFastest
                                  @sprites["pokemon2"]=PokemonSprite.new(@viewport)
                                  @sprites["pokemon2"].setPokemonBitmap(@pokeorder[1],true)
                                  @sprites["pokemon2"].mirror=true
                                  pokemony=Graphics.height/2-32
                                  pokemonyadjust=pokemony-32
                                  pbPositionPokemonSprite(@sprites["pokemon2"],178,112)
                                  end
                                  def pbDisplayThirdFastest
                                  @sprites["pokemon3"]=PokemonSprite.new(@viewport)
                                  @sprites["pokemon3"].setPokemonBitmap(@pokeorder[2],true)
                                  @sprites["pokemon3"].mirror=true
                                  pokemony=Graphics.height/2-32
                                  pokemonyadjust=pokemony-32
                                  pbPositionPokemonSprite(@sprites["pokemon3"],178,112)
                                  end
                                  def pbDisplayFourthFastest
                                  @sprites["pokemon4"]=PokemonSprite.new(@viewport)
                                  @sprites["pokemon4"].setPokemonBitmap(@pokeorder[3],true)
                                  @sprites["pokemon4"].mirror=true
                                  pokemony=Graphics.height/2-32
                                  pokemonyadjust=pokemony-32
                                  pbPositionPokemonSprite(@sprites["pokemon4"],178,112)
                                  end

                                  #Didn't use this method
                                  def pbCurrentPokeNum(currentpos) #find pokemon's number (i.e. 1 for @pkmn1)
                                  case @pokeorder[currentpos-1]
                                  when @pkmn1
                                  return 1
                                  when @pkmn2
                                  return 2
                                  when @pkmn3
                                  return 3
                                  else pkmn4
                                  return 4
                                  end
                                  end

                                  def pbCurrentPokeNum2(poke) #find pokemon's number (i.e. 1 for @pkmn1)
                                  for i in 0..3
                                  if @pokeorder[i]==poke
                                  return i
                                  end
                                  end
                                  end


                                  def pbResetContestMoveEffects #End round reset
                                  @Oblivious=[false,false,false,false]
                                  @AvoidOnce=[0,0,0,0]
                                  @Scramble=false
                                  @MoveUp=[false,false,false,false]
                                  @MoveDown=[false,false,false,false]
                                  @UpCondition=[false,false,false,false]
                                  @previoushearts=0
                                  @crowdexcitment=true
                                  @goodappeal=[false,false,false,false]
                                  @easilystartled=[false,false,false,false]
                                  @nervous=[false,false,false,false]
                                  @jamaffected=[false,false,false,false]
                                  @hasattention=[false,false,false,false]
                                  pbNervousGraphic
                                  pbObliviousGraphic
                                  end


                                  ###############################################################################
                                  # Adjusts hearts via movefunctions. New move functions go in case statement
                                  ###############################################################################
                                  def pbFunctionsAdjustHearts
                                  contestmovedata=PBContestMoveData.new(@currentmove)
                                  @currentfunction=contestmovedata.contestfunction
                                  @currentjam=contestmovedata.jam
                                  [email protected]
                                  case @currentfunction
                                  when 1
                                  @AvoidOnce[i]=1
                                  pbObliviousGraphic
                                  when 2
                                  @Oblivious[i]=true
                                  pbObliviousGraphic
                                  when 3
                                  @MoveUp[i]=true
                                  when 4
                                  @UpCondition[i]=true
                                  when 5
                                  Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the other Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  if @currentpos==4
                                  if @Oblivious[2]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[2]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[2]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(2)
                                  pbJam(@currentjam,@pokeorder[2],3)
                                  pbDecreaseHearts(@pokeorder[2],3)
                                  pbStartleGraphic(2,2)
                                  end
                                  if @Oblivious[1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[1]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[1]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(1)
                                  pbJam(@currentjam,@pokeorder[1],2)
                                  pbDecreaseHearts(@pokeorder[1],2)
                                  pbStartleGraphic(1,1)
                                  end
                                  if @Oblivious[0]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[0]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[0]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(0)
                                  pbJam(@currentjam,@pokeorder[0],1)
                                  pbDecreaseHearts(@pokeorder[0],1)
                                  pbStartleGraphic(0,0)
                                  end
                                  elsif @currentpos==3
                                  if @Oblivious[1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[1]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[1]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(1)
                                  pbJam(@currentjam,@pokeorder[1],2)
                                  pbDecreaseHearts(@pokeorder[1],2)
                                  pbStartleGraphic(1,1)
                                  end
                                  if @Oblivious[0]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[0]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[0]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(0)
                                  pbJam(@currentjam,@pokeorder[0],1)
                                  pbDecreaseHearts(@pokeorder[0],1)
                                  pbStartleGraphic(0,0)
                                  end
                                  elsif @currentpos==2
                                  if @Oblivious[0]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[0]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[0]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(0)
                                  pbJam(@currentjam,@pokeorder[0],1)
                                  pbDecreaseHearts(@pokeorder[0],1)
                                  pbStartleGraphic(0,0)
                                  end
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]But it failed.."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  end
                                  when 6
                                  @[email protected]
                                  @currenthearts=(@currentpos+1) if @currenpos==4
                                  when 7
                                  for j in 0...3
                                  if @hasattention[j]==true && !([email protected])
                                  if @Oblivious[j]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[j]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[j]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(j-1)
                                  pbJam(@currentjam,@pokeorder[j],j+1)
                                  pbDecreaseHearts(@pokeorder[j],j+1)
                                  pbStartleGraphic(j-1,j-1)
                                  end
                                  end
                                  end
                                  when 8
                                  Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the previous Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  if @currentpos==4
                                  if @Oblivious[2]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[2]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[2]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(2)
                                  pbJam(@currentjam,@pokeorder[2],3)
                                  pbDecreaseHearts(@pokeorder[2],3)
                                  pbStartleGraphic(2,2)
                                  end
                                  elsif @currentpos==3
                                  if @Oblivious[1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[1]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[1]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(1)
                                  pbJam(@currentjam,@pokeorder[1],2)
                                  pbDecreaseHearts(@pokeorder[1],2)
                                  pbStartleGraphic(1,1)
                                  end
                                  elsif @currentpos==2
                                  if @Oblivious[0]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[0]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[0]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(0)
                                  pbJam(@currentjam,@pokeorder[0],1)
                                  pbDecreaseHearts(@pokeorder[0],1)
                                  pbStartleGraphic(0,0)
                                  end
                                  else
                                  end
                                  when 9
                                  if @priorhearts[@currentpos-1]>=3
                                  @currenthearts=(@currenthearts*2)
                                  else
                                  @currenthearts==1
                                  end
                                  when 10
                                  @easilystartled[i]=true
                                  when 11
                                  @MoveDown[i]=true
                                  when 12
                                  for j in 0..3
                                  if @priorhearts[j]>3
                                  if @Oblivious[j]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[j]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[j]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(j-1)
                                  pbJam(@currentjam,@pokeorder[j],j+1)
                                  pbDecreaseHearts(@pokeorder[j],j+1)
                                  pbStartleGraphic(j-1,j-1)
                                  end
                                  end
                                  end
                                  when 13
                                  Kernel.pbCustomMessage(_INTL("\\l[3]The crowd died down!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @crowdexcitment=false
                                  when 14
                                  if @currentpos==1
                                  Kernel.pbCustomMessage(_INTL("\\l[3]The standout {1} hustled even more!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @currenthearts=(@currenthearts*2)
                                  end
                                  when 16
                                  pbSetMissTurn
                                  Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the other Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  if @currentpos==4
                                  if @Oblivious[2]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[2]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[2]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(2)
                                  pbJam(@currentjam,@pokeorder[2],3)
                                  pbDecreaseHearts(@pokeorder[2],3)
                                  pbStartleGraphic(2,2)
                                  end
                                  if @Oblivious[1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[1]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[1]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(1)
                                  pbJam(@currentjam,@pokeorder[1],2)
                                  pbDecreaseHearts(@pokeorder[1],2)
                                  pbStartleGraphic(1,1)
                                  end
                                  if @Oblivious[0]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[0]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[0]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(0)
                                  pbJam(@currentjam,@pokeorder[0],1)
                                  pbDecreaseHearts(@pokeorder[0],1)
                                  pbStartleGraphic(0,0)
                                  end
                                  elsif @currentpos==3
                                  if @Oblivious[1]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[1]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[1]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(1)
                                  pbJam(@currentjam,@pokeorder[1],2)
                                  pbDecreaseHearts(@pokeorder[1],2)
                                  pbStartleGraphic(1,1)
                                  end
                                  if @Oblivious[0]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[0]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[0]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(0)
                                  pbJam(@currentjam,@pokeorder[0],1)
                                  pbDecreaseHearts(@pokeorder[0],1)
                                  pbStartleGraphic(0,0)
                                  end
                                  elsif @currentpos==2
                                  if @Oblivious[0]==true
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif @AvoidOnce[0]>0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @AvoidOnce[0]=0
                                  pbObliviousGraphic
                                  else
                                  pbStartleGraphic(0)
                                  pbJam(@currentjam,@pokeorder[0],1)
                                  pbDecreaseHearts(@pokeorder[0],1)
                                  pbStartleGraphic(0,0)
                                  end
                                  else
                                  end
                                  when 17
                                  if @currentpos==1
                                  for j in 1..3
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @nervous[j]=true
                                  end
                                  elsif @currentpos==2
                                  for i in 2..3
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @nervous[j]=true
                                  end
                                  elsif @currentpos==3
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @nervous[3]=true
                                  end
                                  pbNervousGraphic
                                  when 18
                                  pbSetNoMoreMoves
                                  when 19
                                  @currenthearts=(@applause+1)
                                  when 20
                                  @currenthearts=(rand(5)+1)
                                  when 21
                                  if @currentpos==4
                                  Kernel.pbCustomMessage(_INTL("\\l[3]The standout {1} hustled even more!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @currenthearts=5
                                  end
                                  when 22
                                  if @currentpos==0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]But it failed."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  else
                                  for j in [email protected]
                                  pbDecreaseStarGraphics(j,1)
                                  end
                                  end
                                  when 23
                                  @[email protected]
                                  @currenthearts=(@currentpos+1) if @currenpos==4
                                  when 24
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} scrambled up the order for the next turn!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @Scramble=true
                                  when 25
                                  if @[email protected]
                                  @currenthearts=(@currenthearts*2)
                                  end
                                  when 26
                                  @MoveDown[i]=true
                                  when 27
                                  pbSetDoubleNext
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1} is getting prepared.",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @currenthearts=1
                                  when 28
                                  @currenthearts=(rand(5)+1)
                                  when 29
                                  if @currentpos==1
                                  @currenthearts=1
                                  else
                                  if @priorhearts[@currentpos-1]<3
                                  @currenthearts=(@currenthearts*2)
                                  else
                                  @currenthearts=1
                                  end
                                  end
                                  when 30
                                  if @currentpos==1
                                  @currenthearts=1
                                  else
                                  @currenthearts=(@priorhearts[currentpos-1]/2).floor
                                  end
                                  when 31
                                  @applause=5
                                  pbCrowd(move="notnil")
                                  when 32
                                  if @currentpos==0
                                  Kernel.pbCustomMessage(_INTL("\\l[3]But if failed."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  elsif
                                  for j in [email protected]
                                  if @stars[j]>0
                                  pbDecreaseStarGraphics(j,1)
                                  end
                                  end
                                  end
                                  when 33
                                  @[email protected]
                                  when 34
                                  @[email protected][currentpos-1]
                                  when 35
                                  @[email protected][@currentpos-1]
                                  when 36
                                  if @[email protected]
                                  @currenthearts=(@currenthearts+1)
                                  else
                                  @[email protected]
                                  end
                                  when 37
                                  @currenthearts=(@[email protected][@currentpos-1])
                                  when 38
                                  currentApplause = @applause
                                  currentApplause = 5 if currentApplause<0 || 5<currentApplause
                                  @currenthearts=6-currentApplause
                                  when 39
                                  @currenthearts=(@round+1)
                                  when 40
                                  if @currentpos>1
                                  if @priorhearts[@currentpos-1] >3
                                  @currenthearts=(@currenthearts*2)
                                  end
                                  else
                                  @currenthearts=1
                                  end
                                  when 41
                                  @[email protected]
                                  else
                                  @[email protected]
                                  end
                                  end

                                  ###############################################################################
                                  # Controls Applause meter
                                  ###############################################################################
                                  def pbCrowd(move=nil)
                                  xPos=-172
                                  @sprites["Applause Bar"]=IconSprite.new(xPos,0,@viewport)
                                  @sprites["Applause Bar"].setBitmap("Graphics/Pictures/Contest/applause")
                                  applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
                                  @sprites["applausemeter"]=IconSprite.new((xPos+19),50,@viewport)
                                  @sprites["applausemeter"].setBitmap(applausefile)
                                  43.times do |i|
                                  xPos+=4
                                  @sprites["applausemeter"].x=(xPos+19)
                                  @sprites["Applause Bar"].x=xPos
                                  Graphics.update
                                  end
                                  if move==nil
                                  if @[email protected]
                                  @applause=(@applause+1)
                                  applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
                                  @sprites["applausemeter"].setBitmap(applausefile)
                                  Graphics.update
                                  if @moveType=="Beauty"
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2} went over great!",@pokeorder[@currentpos-1].name,@contestType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2}ness went over great!",@pokeorder[@currentpos-1].name,@contestType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  end
                                  @currenthearts=1
                                  pbDisplayAddingPositiveHearts
                                  else
                                  if @moveType=="Beauty"
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2} didn't go over very well!",@pokeorder[@currentpos-1].name,@moveType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  else
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2}ness didn't go over very well!",@pokeorder[@currentpos-1].name,@moveType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  end
                                  if @applause>0
                                  @applause-=1
                                  applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
                                  @sprites["applausemeter"].setBitmap(applausefile)
                                  end
                                  pbJam(1,@pokeorder[@currentpos-1],@currentpos)
                                  pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,"notnil")
                                  Graphics.update
                                  end
                                  if @crowdexcitment==true && @applause==5
                                  Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2} really got the crowd going!",@pokeorder[@currentpos-1].name,@moveType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
                                  @currenthearts=5
                                  pbDisplayAddingPositiveHearts
                                  @applause=0
                                  end
                                  if @sprites["Applause Bar"]
                                  43.times do |i|
                                  xPos-=4
                                  @sprites["Applause Bar"].x=xPos
                                  @sprites["applausemeter"].x=xPos+19 if @sprites["applausemeter"]
                                  Graphics.update
                                  end
                                  end
                                  pbDisposeSprite(@sprites,"Applause Bar") if @sprites["Applause Bar"]
                                  pbDisposeSprite(@sprites,"applausemeter") if @sprites["applausemeter"]
                                  Graphics.update
                                  end
                                  end

                                  def pbJam(jam,target,position)
                                  case target
                                  when @pkmn1
                                  @pkmn1jam=jam
                                  when @pkmn2
                                  @pkmn2jam=jam
                                  when @pkmn3
                                  @pkmn3jam=jam
                                  else
                                  @pkmn4jam=jam
                                  end
                                  end

                                  ###############################################################################
                                  # Miscellaneous Graphic functions
                                  ###############################################################################
                                  def pbNervousGraphic
                                  if @nervous[0]==true && [email protected]["nervousone"]
                                  @sprites["nervousone"]=IconSprite.new(374,47,@viewport)
                                  @sprites["nervousone"].setBitmap("Graphics/Pictures/Contest/nervous")
                                  end
                                  if @nervous[1]==true && [email protected]["nervoustwo"]
                                  @sprites["nervoustwo"]=IconSprite.new(374,143,@viewport)
                                  @sprites["nervoustwo"].setBitmap("Graphics/Pictures/Contest/nervous")
                                  end
                                  if @nervous[2]==true && [email protected]["nervousthree"]
                                  @sprites["nervousthree"]=IconSprite.new(374,239,@viewport)
                                  @sprites["nervousthree"].setBitmap("Graphics/Pictures/Contest/nervous")
                                  end
                                  if @nervous[3]==true && [email protected]["nervousfour"]
                                  @sprites["nervousfour"]=IconSprite.new(374,335,@viewport)
                                  @sprites["nervousfour"].setBitmap("Graphics/Pictures/Contest/nervous")
                                  end
                                  if @nervous[0]==false
                                  pbDisposeSprite(@sprites,"nervousone") if @sprites["nervousone"]
                                  end
                                  if @nervous[1]==false
                                  pbDisposeSprite(@sprites,"nervoustwo") if @sprites["nervoustwo"]
                                  end
                                  if @nervous[2]==false
                                  pbDisposeSprite(@sprites,"nervousthree") if @sprites["nervousthree"]
                                  end
                                  if @nervous[3]==false
                                  pbDisposeSprite(@sprites,"nervousfour") if @sprites["nervousfour"]
                                  end
                                  end

                                  def pbObliviousGraphic
                                  if (@Oblivious[0]==true || @AvoidOnce[0]>0) && [email protected]["obliviousone"]
                                  @sprites["obliviousone"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
                                  @sprites["obliviousone"].setBitmap("Graphics/Pictures/Contest/oblivious")
                                  end
                                  if (@Oblivious[1]==true || @AvoidOnce[1]>0) && [email protected]["oblivioustwo"]
                                  @sprites["oblivioustwo"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
                                  @sprites["oblivioustwo"].setBitmap("Graphics/Pictures/Contest/oblivious")
                                  end
                                  if (@Oblivious[2]==true || @AvoidOnce[2]>0) && [email protected]["obliviousthree"]
                                  @sprites["obliviousthree"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
                                  @sprites["obliviousthree"].setBitmap("Graphics/Pictures/Contest/oblivious")
                                  end
                                  if (@Oblivious[3]==true || @AvoidOnce[3]>0) && [email protected]["obliviousfour"]
                                  @sprites["obliviousfour"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
                                  @sprites["obliviousfour"].setBitmap("Graphics/Pictures/Contest/oblivious")
                                  end
                                  if @Oblivious[0]==false && @AvoidOnce[0]==0
                                  pbDisposeSprite(@sprites,"obliviousone") if @sprites["obliviousone"]
                                  end
                                  if @Oblivious[1]==false && @AvoidOnce[1]==0
                                  pbDisposeSprite(@sprites,"oblivioustwo") if @sprites["oblivioustwo"]
                                  end
                                  if @Oblivious[2]==false && @AvoidOnce[2]==0
                                  pbDisposeSprite(@sprites,"obliviousthree") if @sprites["obliviousthree"]
                                  end
                                  if @Oblivious[3]==false && @AvoidOnce[3]==0
                                  pbDisposeSprite(@sprites,"obliviousfour") if @sprites["obliviousfour"]
                                  end
                                  end

                                  def pbStartleGraphic(position,deletepos=5)
                                  if position==0 && [email protected]["startleone"]
                                  @sprites["startleone"]=IconSprite.new(374,47,@viewport)
                                  @sprites["startleone"].setBitmap("Graphics/Pictures/Contest/startle")
                                  end
                                  if position==1 && [email protected]["startletwo"]
                                  @sprites["startletwo"]=IconSprite.new(374,143,@viewport)
                                  @sprites["startletwo"].setBitmap("Graphics/Pictures/Contest/startle")
                                  end
                                  if position==2 && [email protected]["startlethree"]
                                  @sprites["startlethree"]=IconSprite.new(374,239,@viewport)
                                  @sprites["startlethree"].setBitmap("Graphics/Pictures/Contest/startle")
                                  end
                                  if position==3 && [email protected]["startlefour"]
                                  @sprites["startlefour"]=IconSprite.new(374,335,@viewport)
                                  @sprites["startlefour"].setBitmap("Graphics/Pictures/Contest/startle")
                                  end
                                  if deletepos<5
                                  if deletepos==0
                                  pbDisposeSprite(@sprites,"startleone") if @sprites["startleone"]
                                  end
                                  if deletepos==1
                                  pbDisposeSprite(@sprites,"startletwo") if @sprites["startletwo"]
                                  end
                                  if deletepos==2
                                  pbDisposeSprite(@sprites,"startlethree") if @sprites["startlethree"]
                                  end
                                  if deletepos==3
                                  pbDisposeSprite(@sprites,"startlefour") if @sprites["startlefour"]
                                  end
                                  end
                                  Graphics.update
                                  end

                                  def pbDecreaseStarGraphics(position,change,decrease=true)
                                  case @stars[position]
                                  when @pkmn1stars
                                  for i in 0..change
                                  @pkmn1stars -= 1 if decrease==true && @pkmn1stars>0
                                  @pkmn1stars += 1 if decrease==false
                                  @sprites["firstpokestars"]=IconSprite.new(350,78+(94*position),@viewport) unless @sprites["firstpokestars"]
                                  starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn1stars) if @pkmn1stars<=6
                                  @sprites["firstpokestars"].setBitmap(starfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  break if @pkmn1stars==0
                                  end
                                  when @pkmn2stars
                                  for i in 0..change
                                  @pkmn2stars -= 1 if decrease==true && @pkmn2stars>0
                                  @pkmn2stars += 1 if decrease==false
                                  @sprites["secondpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["secondpokestars"]
                                  starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn2stars) if @pkmn2stars<=6
                                  @sprites["secondpokestars"].setBitmap(starfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  break if @pkmn2stars==0
                                  end
                                  when @pkmn3stars
                                  for i in 0..change
                                  @pkmn3stars -= 1 if decrease==true && @pkmn3stars>0
                                  @pkmn3stars += 1 if decrease==false
                                  @sprites["thirdpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["thirdpokestars"]
                                  starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn3stars) if @pkmn3stars<=6
                                  @sprites["thirdpokestars"].setBitmap(starfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  break if @pkmn3stars==0
                                  end
                                  when @pkmn4stars
                                  for i in 0..change
                                  @pkmn4stars -= 1 if decrease==true && @pkmn4stars>0
                                  @pkmn4stars += 1 if decrease==false
                                  @sprites["fourthpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["fourthpokestars"]
                                  starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn4stars) if @pkmn4stars<=6
                                  @sprites["fourthpokestars"].setBitmap(starfile)
                                  sleep(1.0/7.0)
                                  Graphics.update
                                  break if @pkmn4stars==0
                                  end
                                  end
                                  end

                                  ################################################################################
                                  # Move Buttons
                                  ################################################################################
                                  def pbMoveButtons
                                  [email protected]
                                  pokename=pokemon.name
                                  @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                                  @viewport.z=99999
                                  @sprites["moves"]=IconSprite.new(0,187,@viewport)
                                  @sprites["moves"].setBitmap("Graphics/Pictures/Contest/moves")
                                  base=Color.new(64,64,64)
                                  shadow=Color.new(0,0,0)
                                  @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                                  @sprites["overlay1"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
                                  [email protected]["overlay"].bitmap
                                  [email protected]["overlay1"].bitmap
                                  pbSetSmallFont(overlay)
                                  textpos=[
                                  [_INTL("Please select a move."),12,165,0,Color.new(256,256,256),shadow]]
                                  imagepos=[]
                                  textpos1=[]
                                  yPos=195
                                  xPos=10
                                  selectYPos=191
                                  @sprites["selectbar"]=IconSprite.new(6,selectYPos,@viewport)
                                  @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1")
                                  selection=0
                                  selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
                                  for i in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(i)
                                  if selectedmove==name
                                  selectedmove=getID(PBContestMoves,i)
                                  end
                                  end
                                  selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
                                  contestmovedata=PBContestMoveData.new(selectedmove)
                                  selectedhearts=contestmovedata.hearts
                                  selectedjam=contestmovedata.jam
                                  jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
                                  @sprites["selectjam"]=IconSprite.new(400,235,@viewport)
                                  @sprites["selectjam"].setBitmap(jamfile)
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
                                  @sprites["selecthearts"]=IconSprite.new(400,200,@viewport)
                                  @sprites["selecthearts"].setBitmap(heartfile)
                                  textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
                                  Color.new(256,256,256),Color.new(0,0,0)])
                                  pbDrawTextPositions(overlay1,textpos1)
                                  drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
                                  for i in 0...pokemon.moves.length
                                  if pokemon.moves[i].id>0
                                  selectedmove=PBMoves.getName(@pkmn1.moves[i].id)
                                  for j in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(j)
                                  if selectedmove==name
                                  selectedmove=getID(PBContestMoves,j)
                                  end
                                  end

                                  contestmovedata=PBContestMoveData.new(selectedmove)
                                  moveType=contestmovedata.contestType
                                  imagepos.push(["Graphics/Pictures/Contest/contesttype",xPos,yPos,0,
                                  moveType*28,64,28])
                                  if @pkmn1lastmove && PBMoves.getName(pokemon.moves[i].id)[email protected]
                                  textpos.push([PBMoves.getName(pokemon.moves[i].id),xPos+68,yPos+10,0,Color.new(175,175,175),Color.new(0,0,0)])
                                  else
                                  textpos.push([PBMoves.getName(pokemon.moves[i].id),xPos+68,yPos+10,0,Color.new(256,256,256),Color.new(0,0,0)])
                                  end
                                  else
                                  textpos.push(["-",316,yPos,0,Color.new(256,256,256),Color.new(0,0,0)])
                                  end
                                  yPos+=44
                                  end
                                  pbDrawTextPositions(overlay,textpos)
                                  pbDrawImagePositions(overlay,imagepos)
                                  loop do
                                  Graphics.update
                                  Input.update
                                  self.update
                                  if Input.trigger?(Input::DOWN)
                                  if selection<3
                                  selection+=1
                                  else
                                  selection=0
                                  end
                                  selectYPos=(selection*45 + 192)
                                  selectYPos=(selection*45+191) if selection==0
                                  selectYPos=(selection*45+190) if selection==1
                                  @sprites["selectbar"].y=selectYPos
                                  @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1") if selection==0
                                  @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect") if selection!=0
                                  selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
                                  for i in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(i)
                                  if selectedmove==name
                                  selectedmove=getID(PBContestMoves,i)
                                  end
                                  end
                                  contestmovedata=PBContestMoveData.new(selectedmove)
                                  selectedhearts=contestmovedata.hearts
                                  selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
                                  selectedjam=contestmovedata.jam
                                  jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
                                  @sprites["selectjam"].setBitmap(jamfile)
                                  @sprites["selecthearts"].setBitmap(heartfile)
                                  overlay1.clear
                                  textpos1.clear
                                  @sprites["overlay1"].bitmap
                                  textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
                                  Color.new(256,256,256),Color.new(0,0,0)])
                                  drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
                                  pbDrawTextPositions(overlay1,textpos1)
                                  end
                                  if Input.trigger?(Input::UP)
                                  if selection>0
                                  selection-=1
                                  else
                                  selection=3
                                  end
                                  selectYPos=(selection*45 + 192)
                                  selectYPos=(selection*45+191) if selection==0
                                  selectYPos=(selection*45+190) if selection==1
                                  @sprites["selectbar"].y=selectYPos
                                  @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1") if selection==0
                                  @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect") if selection!=0
                                  selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
                                  for i in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(i)
                                  if selectedmove==name
                                  selectedmove=getID(PBContestMoves,i)
                                  end
                                  end
                                  contestmovedata=PBContestMoveData.new(selectedmove)
                                  selectedhearts=contestmovedata.hearts
                                  selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
                                  selectedjam=contestmovedata.jam
                                  jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
                                  @sprites["selectjam"].setBitmap(jamfile)
                                  heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
                                  @sprites["selecthearts"].setBitmap(heartfile)
                                  overlay1.clear
                                  textpos1.clear
                                  @sprites["overlay1"].bitmap
                                  textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
                                  Color.new(256,256,256),Color.new(0,0,0)])
                                  drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
                                  pbDrawTextPositions(overlay1,textpos1)
                                  end
                                  if Input.trigger?(Input::C)
                                  @moveselection=selection
                                  overlay.clear
                                  overlay1.clear
                                  textpos.clear
                                  imagepos.clear
                                  textpos1.clear
                                  pbDisposeSprite(@sprites,"selecthearts")
                                  pbDisposeSprite(@sprites,"moves")
                                  pbDisposeSprite(@sprites,"selectbar")
                                  pbDisposeSprite(@sprites,"selectjam")
                                  pbDisposeSprite(@sprites,"overlay")
                                  pbDisposeSprite(@sprites,"overlay1")
                                  Graphics.update
                                  break
                                  end
                                  end
                                  end

                                  def pbEndScene #Ends everything
                                  for i in 0..3
                                  CONTESTMOVE2[i]=0 #reset these global variables for next use
                                  CONTESTMOVE3[i]=0
                                  CONTESTMOVE4[i]=0
                                  end
                                  $CONTESTNAME2="" #reset these global variables for next use
                                  $CONTESTNAME3=""
                                  $CONTESTNAME4=""
                                  $game_map.autoplay
                                  pbFadeOutAndHide(@sprites) { update }
                                  pbDisposeSpriteHash(@sprites)
                                  @viewport.dispose
                                  $scene = Scene_Map.new
                                  end

                                  def middleScene #processes scene after startScene
                                  loop do
                                  Graphics.update
                                  Input.update
                                  self.update
                                  if @contestover
                                  break
                                  end
                                  end
                                  end
                                  ###############################################################################
                                  #################### Animation Stuff Below ###################################
                                  ############## Don't change unless you know what you're doing #################
                                  ###############################################################################
                                  def pbFindAnimation(moveid,userIndex,hitnum)
                                  begin
                                  move2anim=load_data("Data/move2anim.dat")
                                  noflip=false
                                  if (userIndex&1)==0 # On player's side
                                  anim=move2anim[0][moveid]
                                  else # On opposing side
                                  anim=move2anim[1][moveid]
                                  noflip=true if anim
                                  anim=move2anim[0][moveid] if !anim
                                  end
                                  return [anim+hitnum,noflip] if anim
                                  if hasConst?(PBMoves,:TACKLE)
                                  anim=move2anim[0][getConst(PBMoves,:TACKLE)]
                                  return [anim,false] if anim
                                  end
                                  rescue
                                  return nil
                                  end
                                  return nil
                                  end

                                  def pbAnimation(moveid,user,target,hitnum=0)
                                  animid=pbFindAnimation(moveid,0,hitnum)
                                  return if !animid
                                  anim=animid[0]
                                  animations=load_data("Data/PkmnAnimations.rxdata")
                                  pbSaveShadows {
                                  if animid[1] # On opposing side and using OppMove animation
                                  pbAnimationCore(animations[anim],target,user)
                                  else # On player's side, and/or using Move animation
                                  pbAnimationCore(animations[anim],user,target)
                                  end
                                  }
                                  end

                                  def pbSaveShadows
                                  shadows=[]
                                  for i in 0...4
                                  [email protected]["shadow#{i}"]
                                  shadows[i]=s ? s.visible : false
                                  s.visible=false if s
                                  end
                                  yield
                                  for i in 0...4
                                  [email protected]["shadow#{i}"]
                                  s.visible=shadows[i] if s
                                  end
                                  end

                                  def pbAnimationCore(animation,user,target)
                                  return if !animation
                                  @briefmessage=false
                                  case @currentpos
                                  when 1
                                  [email protected]["pokemon1"]
                                  when 2
                                  [email protected]["pokemon2"]
                                  when 3
                                  [email protected]["pokemon3"]
                                  when 4
                                  [email protected]["pokemon4"]
                                  end
                                  targetsprite=(@atself==false)? @sprites["opponent"]:usersprite
                                  olduserx=usersprite ? usersprite.x : 0
                                  oldusery=usersprite ? usersprite.y : 0
                                  oldtargetx=targetsprite ? targetsprite.x : 0
                                  oldtargety=targetsprite ? targetsprite.y : 0
                                  #Start animation player
                                  animplayer=PBAnimationPlayerContest.new(animation,user,target,usersprite,targetsprite,self)
                                  userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
                                  userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
                                  targetwidth=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.width
                                  targetheight=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.height
                                  animplayer.setLineTransform(
                                  PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
                                  PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
                                  olduserx+(userwidth/2),oldusery+(userheight/2),
                                  oldtargetx+(targetwidth/2),oldtargety+(targetheight/2))
                                  animplayer.start
                                  while animplayer.playing?
                                  animplayer.update
                                  Graphics.update
                                  end
                                  usersprite.ox=0 if usersprite
                                  usersprite.oy=0 if usersprite
                                  usersprite.x=olduserx if usersprite
                                  usersprite.y=oldusery if usersprite
                                  targetsprite.ox=0 if targetsprite
                                  targetsprite.oy=0 if targetsprite
                                  targetsprite.x=oldtargetx if targetsprite
                                  targetsprite.y=oldtargety if targetsprite
                                  animplayer.dispose
                                  end

                                  # End of Animation Stuff
                                  ###############################################################################



                                  ###############################################################################
                                  # AI
                                  ###############################################################################
                                  def pbAI(pokemon,difficulty)
                                  movescores=[]
                                  nummoves=pokemon.moves.length
                                  for i in 0...nummoves
                                  score=100
                                  move=PBMoves.getName(pokemon.moves[i].id)
                                  currentmovename=PBMoves.getName(pokemon.moves[i].id)
                                  if pokemon.moves[i].id>0
                                  for j in 1..PBContestMoves.maxValue
                                  name=PBContestMoves.getName(j)
                                  if move==name
                                  move=getID(PBContestMoves,j)
                                  end
                                  end
                                  contestmovedata=PBContestMoveData.new(move)
                                  hearts=contestmovedata.hearts
                                  jam=contestmovedata.jam
                                  function=contestmovedata.contestfunction
                                  type=contestmovedata.contestType
                                  case function
                                  when 0 #No function
                                  score+=60 if hearts>3
                                  score+=30 if hearts<=3
                                  when 1,2 #gains oblivious. Increase score for earlier position
                                  case @currentpos
                                  when 1
                                  score+=60
                                  when 2
                                  score+=40
                                  when 4
                                  score-=20
                                  end
                                  when 3 #Move Up in order
                                  if @currentpos==4
                                  score+=30
                                  else
                                  score+=10
                                  end
                                  when 4 #Ups condition
                                  score+=30
                                  when 5 #Tries to startle previous pokemons
                                  case @currentpos
                                  when 4
                                  score+=70
                                  when 3
                                  score+=40
                                  when 1
                                  score-=20
                                  end
                                  when 6,23 #works better later
                                  case @currentpos
                                  when 4
                                  score+=70
                                  when 3
                                  score+=40
                                  when 1
                                  score-=20
                                  end
                                  when 7 #deducts from pokemon that has judges attention
                                  for k in [email protected]
                                  score+=30 if @hasattention[k]==true
                                  end
                                  when 8 #startles pokemon in front
                                  case @currentpos
                                  when 4
                                  score+=40
                                  when 3
                                  score+=20
                                  when 1
                                  score-=20
                                  end
                                  when 9,40 #better if previous move was better
                                  if @priorhearts>=3
                                  score+=60
                                  else
                                  score-=20
                                  end
                                  when 10 #easily startled
                                  case @currentpos
                                  when 4
                                  score+=60
                                  when 3
                                  score+=40
                                  when 1
                                  score-=20
                                  end
                                  when 11 #move down in order
                                  if @currentpos==4
                                  score-=20
                                  else
                                  score+=20
                                  end
                                  when 12 #startles pokemon with good appeals
                                  case @currentpos
                                  when 4
                                  score+=20
                                  score+=30 if @priorhearts>3
                                  when 3
                                  score+=10
                                  score+=30 if @priorhearts>3
                                  when 1
                                  score-=20
                                  end
                                  when 13 #stops crowd excitement
                                  score -=20 if @applause>3
                                  score +=20 if @applause<=3
                                  when 14 #works best if performed first
                                  if @currentpos==1
                                  score+=60
                                  end
                                  when 15 #can be used multiple times without boring judge
                                  score+=20
                                  when 16 #jams pokemon and misses turn
                                  case @currentpos
                                  when 4
                                  score+=30
                                  when 3
                                  score+=20
                                  end
                                  if @round==5
                                  score+=60
                                  elsif @round==1
                                  score-=10
                                  end
                                  when 17 #makes all pokemon after nervous
                                  case @currentpos
                                  when 1
                                  score+=60
                                  when 2
                                  score+=40
                                  when 4
                                  score-=20
                                  end
                                  when 18 #no more moves
                                  if @round==5
                                  score+=90
                                  else
                                  score-=60
                                  end
                                  when 19 #depends on applause level
                                  score+=20 if @applause>2
                                  when 20 #depends on random
                                  score+=20
                                  when 21 #best if performed last
                                  if @currentpos==4
                                  score+=60
                                  end
                                  when 22,32 #removes a star
                                  if @currentpos==4 && @stars.max>1 && @stars.index(@stars.max)[email protected]
                                  score+=40
                                  end
                                  when 24 #Scramble
                                  if @round !=5
                                  score+=30
                                  end
                                  when 25 #works better if last move type is the same
                                  if @lastmoveType && [email protected]
                                  score+=40
                                  else
                                  score-=10
                                  end
                                  when 26 #appeal later next turn
                                  if @currentpos==4
                                  score-=20
                                  else
                                  score+=20
                                  end
                                  when 27 #double next turn
                                  if @round !=5
                                  score+=40
                                  else
                                  score-=60
                                  end
                                  when 28 #random amounts
                                  score+=20
                                  when 29 #better if last pokemon's wasn't
                                  if @priorhearts<3
                                  score+=60
                                  else
                                  score-=20
                                  end
                                  when 30 #half as much as previous pokemon
                                  score+=(@priorhearts/2.floor)*10 if @priorhearts
                                  when 31 #gets crowd going
                                  score+=40
                                  when 33,41 #better based on crowd excitement
                                  score+=(@applause*10).floor
                                  when 34,37 #same amount as last appearl
                                  score+=(@priorhearts.floor)*10 if @priorhearts
                                  when 35 #equals the pokemon's stars
                                  if @stars[@currentpos-1]>0
                                  [email protected][@currentpos-1]*10
                                  else
                                  score-=30
                                  end
                                  when 36
                                  if [email protected]
                                  score+=40
                                  else
                                  score-=10
                                  end
                                  when 38 #better for lower applause
                                  case @applause
                                  when 1
                                  score+=60
                                  when 2
                                  score+=40
                                  when 3
                                  score+=20
                                  when 4
                                  score-=20
                                  end
                                  when 39 #better for later rounds
                                  case @round
                                  when 5
                                  score+=60
                                  when 3
                                  score+=40
                                  when 2
                                  score+=20
                                  when 1
                                  score-=20
                                  end
                                  end
                                  score+=60 if [email protected] #better if it's the same type as the contest
                                  @currentmovename=currentmovename
                                  score+=60 if @round>1 && pbCheckforCombos==true #better if it will result in a combo
                                  score-=40 if @round>1 && function !=15 && pbCheckLast
                                  end
                                  movescores.push(score) if pokemon.moves[i].id>0
                                  end
                                  #movescores have been added up. Now find highest value, with a bit of variation
                                  stdev=pbStdDev(movescores)
                                  choice=movescores.index(movescores.max) #finds highest scoring move
                                  notchoice=movescores.index(movescores.min)
                                  return choice if stdev>=100 && rand(10)!=0 #use the highest scoring move if it's clearly better (stdev of 100 or more)
                                  newmovescores=movescores.clone
                                  newmovescores.sort
                                  secondlowest=movescores.index(newmovescores[1])
                                  r=rand(movescores.length)
                                  movescores[notchoice]=nil if difficulty>25
                                  movescores[secondlowest]=nil if difficulty>75
                                  if difficulty>25 #lowest difficulty
                                  return r if movescores[r]!=nil && rand(10)>4
                                  elsif difficulty>50
                                  return r if movescores[r]!=nil && rand(10)>2
                                  elsif difficulty>75
                                  2.times do
                                  return r if movescores[r]!=nil && rand(10)>2
                                  end
                                  else
                                  return r
                                  end
                                  return r
                                  end

                                  def pbStdDev(scores) #from PokeBattle_AI
                                  n=0
                                  sum=0
                                  scores.each{|s| sum+=s; n+=1 }
                                  return 0 if n==0
                                  mean=sum.to_f/n.to_f
                                  varianceTimesN=0
                                  for i in 0...scores.length
                                  if scores[i]>0
                                  deviation=scores[i].to_f-mean
                                  varianceTimesN+=deviation*deviation
                                  end
                                  end
                                  # Using population standard deviation
                                  # [(n-1) makes it a sample std dev, would be 0 with only 1 sample]
                                  return Math.sqrt(varianceTimesN/n)
                                  end
                                  # End of AI
                                  ###############################################################################
                                  ###############################################################################
                                  # Preliminary Results. No graphics used
                                  ###############################################################################
                                  def pbPreliminaryScene
                                  @prelim1=0
                                  @prelim2=0
                                  @prelim3=0
                                  @prelim4=0
                                  #points for players pokemon below
                                  case @contestType
                                  when "Cool"
                                  @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:REDSCARF)
                                  @prelim1+=($Trainer.party[$game_variables[36]].cool/8).floor
                                  when "Beauty"
                                  @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:BLUESCARF)
                                  @prelim1+=($Trainer.party[$game_variables[36]].beauty/8).floor
                                  when "Smart"
                                  @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:GREENSCARF)
                                  @prelim1+=($Trainer.party[$game_variables[36]].smart/8).floor
                                  when "Tough"
                                  @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:YELLOWSCARF)
                                  @prelim1+=($Trainer.party[$game_variables[36]].tough/8).floor
                                  when "Cute"
                                  @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:PINKSCARF)
                                  @prelim1+=($Trainer.party[$game_variables[36]].cute/8).floor
                                  end
                                  @prelim1+=25 if $Trainer.party[$game_variables[36]].isShiny? #extra points if it's shiny
                                  #points for other pokemon below
                                  #points for coolness, beauty, etc. Pokemon are created with 0, so they won't have any, given by difficulty
                                  @prelim2+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
                                  @prelim3+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
                                  @prelim4+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
                                  #gives points for "scarves". Pokemon won't actually have any. Less likely to
                                  @prelim2+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
                                  @prelim3+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
                                  @prelim4+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
                                  #points for shiny
                                  @prelim2+=25 if @pkmn2.isShiny?
                                  @prelim3+=25 if @pkmn3.isShiny?
                                  @prelim4+=25 if @pkmn4.isShiny?
                                  #add some randomness for opponents
                                  @prelim2+=rand(10)
                                  @prelim2-=rand(10)
                                  @prelim3+=rand(10)
                                  @prelim3-=rand(10)
                                  @prelim4+=rand(10)
                                  @prelim4-=rand(10)
                                  end
                                  ###############################################################################
                                  # Results Scene
                                  ###############################################################################
                                  def pbResultsScene
                                  @sprites["results"]=IconSprite.new(0,0,@viewport2)
                                  @sprites["results"].setBitmap("Graphics/Pictures/Contest/resultsbg")
                                  #draw poke icons
                                  @pkmn1sprite=PokemonIconSprite.new(@pkmn1,@viewport2)
                                  @pkmn2sprite=PokemonIconSprite.new(@pkmn2,@viewport2)
                                  @pkmn3sprite=PokemonIconSprite.new(@pkmn3,@viewport2)
                                  @pkmn4sprite=PokemonIconSprite.new(@pkmn4,@viewport2)
                                  #positions poke icons
                                  @pkmn1sprite.x=86
                                  @pkmn2sprite.x=86
                                  @pkmn3sprite.x=86
                                  @pkmn4sprite.x=86
                                  @pkmn1sprite.y=93
                                  @[email protected]+50
                                  @[email protected]+50
                                  @[email protected]+50
                                  @sprites["textbitmap"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2) #bitmap to draw text on, instead of Kernel.pbMessage
                                  @sprites["textbitmap"][email protected]
                                  #Color for rectangles, determined by contest type
                                  rectcolor=(@contestType=="Cool")?Color.new(178,34,34):(@contestType=="Beauty")?Color.new(0,0,255):(@contestType=="Smart")?Color.new(0,100,0):(@contestType=="Tough")?Color.new(255,215,0):Color.new(255,0,255)
                                  #array of the scores to use
                                  @results=[@prelim1*1.5.floor,@prelim2*1.5.floor,@prelim3*1.5.floor,@prelim4*1.5.floor]
                                  @newstars=[@pkmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
                                  #Draw rectangles, using the prelims as the initial
                                  textpos=[]
                                  textpos.push([_INTL("Preliminary Results"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  @sprites["overlay2"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2)
                                  @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
                                  Graphics.update
                                  sleep(1)
                                  #Draw first round
                                  #this could probably be reduced to one loop, but it'll do more calculations in the long run
                                  textpos.clear
                                  @sprites["textbitmap"].bitmap.clear
                                  textpos.push([_INTL("First Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  3.times do
                                  for i in 0..3
                                  @results[i][email protected][i]*1.5/3
                                  end
                                  @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
                                  Graphics.update
                                  sleep(1)
                                  end
                                  #Draw second round
                                  textpos.clear
                                  @sprites["textbitmap"].bitmap.clear
                                  textpos.push([_INTL("Second Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  3.times do
                                  for i in 0..3
                                  @results[i][email protected][i]*1.5/3
                                  end
                                  @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
                                  Graphics.update
                                  sleep(1)
                                  end
                                  #Draw third round
                                  textpos.clear
                                  @sprites["textbitmap"].bitmap.clear
                                  textpos.push([_INTL("Third Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  3.times do
                                  for i in 0..3
                                  @results[i][email protected][i]*1.5/3
                                  end
                                  @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
                                  Graphics.update
                                  sleep(1)
                                  end
                                  #Draw fourth round
                                  textpos.clear
                                  @sprites["textbitmap"].bitmap.clear
                                  textpos.push([_INTL("Fourth Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  3.times do
                                  for i in 0..3
                                  @results[i][email protected][i]*1.5/3
                                  end
                                  @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
                                  Graphics.update
                                  sleep(1)
                                  end
                                  #Draw fifth round
                                  textpos.clear
                                  @sprites["textbitmap"].bitmap.clear
                                  textpos.push([_INTL("Fifth Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  3.times do
                                  for i in 0..3
                                  @results[i][email protected][i]*1.5/3
                                  end
                                  @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
                                  Graphics.update
                                  sleep(1)
                                  end
                                  #draw Stars
                                  textpos.clear
                                  @sprites["textbitmap"].bitmap.clear
                                  textpos.push([_INTL("Stars Earned"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  3.times do
                                  for i in 0..3
                                  @results[i][email protected][i]*10/3
                                  end
                                  @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
                                  @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
                                  Graphics.update
                                  sleep(1)
                                  end
                                  winner=[@pkmn1total*[email protected][email protected]*10,@pkmn2total*[email protected][email protected]*10,@pkmn3total*[email protected][email protected]*10,@pkmn4total*[email protected][email protected]*10].sort.reverse
                                  win=(winner[0]==(@pkmn1total*[email protected][email protected]*10))? @pkmn1:(winner[0]==(@pkmn2total*[email protected][email protected]*10))? @pkmn2:(winner[0]==(@pkmn3total*[email protected][email protected]*10))? @pkmn3:@pkmn4
                                  textpos.clear
                                  @sprites["textbitmap"].bitmap.clear
                                  textpos.push([(_INTL("{1} is the winner!",win.name)),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
                                  pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
                                  if [email protected]
                                  $Trainer.party[$game_variables[36]].giveRibbon(@ribbonnum) if !($Trainer.party[$game_variables[36]].hasRibbon?(@ribbonnum))
                                  end
                                  Graphics.update
                                  sleep(1)
                                  @pkmn1sprite.dispose
                                  @pkmn2sprite.dispose
                                  @pkmn3sprite.dispose
                                  @pkmn4sprite.dispose
                                  @sprites["overlay2"].bitmap.clear
                                  end
                                  ################################################################################
                                  end

                                  class PokeContest
                                  def initialize(scene)
                                  @scene=scene
                                  end

                                  def pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
                                  @scene.pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
                                  @scene.middleScene
                                  @scene.pbEndScene
                                  end
                                  end


                                  def pbContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
                                  scene=PokeContestScene.new
                                  screen=PokeContest.new(scene)
                                  return screen.pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
                                  end


                                  ################################################################################
                                  # Define Contest Combos here
                                  ################################################################################
                                  #define all combos here. first entry in array starts the combo, the rest are the options to follow it
                                  #name them by their name used in the game, not the internal name
                                  combo1=["Belly Drum","Rest"]
                                  combo2=["Calm Mind","Confusion","Dream Eater","Future Sight","Light Screen","Luster Purge","Meditate","Mist Ball","Psybeam","Psychic","Psycho Boost","Psywave","Reflect"]
                                  combo3=["Charge","Shock Wave","Spark","Thunder","Thunderbolt","Thunder Punch","Thunder Shock","Thunder Wave","Volt Tackle","Zap Cannon"]
                                  combo4=["Charm","Flatter","Growl","Rest","Tail Whip"]
                                  combo5=["Confusion","Future Sight","Kinesis","Psychic","Teleport"]
                                  combo6=["Curse","Destiny Bond","Grudge","Mean Look","Spite"]
                                  combo7=["Defense Curl","Rollout","Tackle"]
                                  combo8=["Dive","Surf"]
                                  combo9=["Double Team","Agility","Quick Attack","Teleport"]
                                  combo10=["Dragon Breath","Dragon Claw","Dragon Dance","Dragon Rage"]
                                  combo11=["Dragon Dance","Dragon Breath","Dragon Claw","Dragon Rage"]
                                  combo12=["Dragon Rage","Dragon Breath","Dragon Claw","Dragon Dance"]
                                  combo13=["Earthquake","Eruption","Fissure"]
                                  combo14=["Endure","Flail","Reversal"]
                                  combo15=["Fake Out","Arm Thrust","Feint Attack","Knock Off","Seismic Toss","Vital Throw"]
                                  combo16=["Fire Punch","Ice Punch","Thunder Punch"]
                                  combo17=["Focus Energy","Arm Thrust","Brick Break","Cross Chop","Double Edge","DynamicPunch","Focus Punch","Headbutt","Karate Chop","Sky Uppercut","Take Down"]
                                  combo18=["Growth","Absorb","Bullet Seed","Frenzy Plant","Giga Drain","Leech Seed","Magical Leaf","Mega Drain","Petal Dance","Razor Leaf","SolarBeam","Vine Whip"]
                                  combo19=["Hail","Aurora Beam","Blizzard","Haze","Ice Ball","Ice Beam","Icicle Spear","Icy Wind","Powder Snow","Sheer Cold","Weather Ball"]
                                  combo20=["Harden","Double Edge","Protect","Rollout","Tackle","Take Down"]
                                  combo21=["Horn Attack","Horn Drill","Fury Attack"]
                                  combo22=["Hypnosis","Dream Eater"]
                                  combo23=["Ice Punch","Fire Punch","Thunder Punch"]
                                  combo24=["Kinesis","Confusion","Future Sight","Psychic","Teleport"]
                                  combo25=["Leer","Bite","Feint Attack","Glare","Horn Attack","Scary Face","Scratch","Stomp","Tackle"]
                                  combo26=["Lock-On","Superpower","Thunder","Tri Attack","Zap Cannon"]
                                  combo27=["Mean Look","Destiny Bond","Perish Song"]
                                  combo28=["Metal Sound","Metal Claw"]
                                  combo29=["Mind Reader","DynamicPunch","Hi Jump Kick","Sheer Cold","Submission","Superpower"]
                                  combo30=["Mud Sport","Mud-Slap","Water Gun","Water Sport"]
                                  combo31=["Peck","Drill Peck","Fury Attack"]
                                  combo32=["Pound","Double Slap","Feint Attack","Slam"]
                                  combo33=["Powder Snow","Blizzard"]
                                  combo34=["Psychic","Confusion","Teleport","Future Sight","Kinesis"]
                                  combo35=["Rage","Leer","Scary Face","Thrash"]
                                  combo36=["Rain Dance","Bubble","Bubblebeam","Clamp","Crabhammer","Dive","Hydro Cannon","Hydro Pump","Muddy Water","Octazooka","Surf","Thunder","Water Gun","Water Pulse","Water Sport","Water Spout","Waterfall","Weather Ball","Whirlpool"]
                                  combo37=["Rest","Sleep Talk","Snore"]
                                  combo38=["Rock Throw","Rock Slide","Rock Tomb"]
                                  combo39=["Sand-Attack","Mud-Slap"]
                                  combo40=["Sandstorm","Mud Shot","Mud-Slap","Mud Sport","Sand Tomb","Sand-Attack","Weather Ball"]
                                  combo41=["Scary Face","Bite","Crunch","Leer"]
                                  combo42=["Scratch","Fury Swipes","Slash"]
                                  combo43=["Sing","Perish Song","Refresh"]
                                  combo44=["Sludge","Sludge Bomb"]
                                  combo45=["Sludge Bomb","Sludge"]
                                  combo46=["Smog","Smokescreen"]
                                  combo47=["Stockpile","Spit Up","Swallow"]
                                  combo48=["Sunny Day","Blast Burn","Blaze Kick","Ember","Eruption","Fire Blast","Fire Punch","Fire Spin","Flame Wheel","Flamethrower","Heat Wave","Moonlight","Morning Sun","Overheat","Sacred Fire","SolarBeam","Synthesis","Weather Ball","Will-o-Wisp"]
                                  combo49=["Surf","Dive"]
                                  combo50=["Sweet Scene","Poison Powder","Sleep Powder","Stun Spore"]
                                  combo51=["Swords Dance","Crabhammer","Crush Claw","Cut","False Swipe","Fury Cutter","Slash"]
                                  combo52=["Taunt","Counter","Detect","Mirror Coat"]
                                  combo53=["Thunder Punch","Fire Punch","Ice Punch"]
                                  combo54=["Vice Grip","Bind","Guillotine"]
                                  combo55=["Water Sport","Mud Sport","Refresh","Water Gun"]
                                  combo56=["Yawn","Rest","Slack Off"]
                                  #add more combos here
                                  #then add them to this array below
                                  CONTESTCOMBOS=[combo1,combo2,combo3,combo4,combo5,combo6,combo7,combo8,combo9,combo10,combo11,combo12,combo13,combo14,combo15,combo16,combo17,combo18,combo19,combo20,combo21,combo22,combo23,combo24,combo25,combo26,combo27,combo28,combo29,combo30,
                                  combo31,combo32,combo33,combo34,combo35,combo36,combo37,combo38,combo39,combo40,combo41,combo42,combo43,combo44,combo45,combo46,combo47,combo48,combo49,combo50,combo51,combo52,combo53,combo54,combo55,combo56]

                                  ################################################################################
                                  # blank array to store moves to teach contest pokemon
                                  ################################################################################
                                  CONTESTMOVE2=[0,0,0,0]
                                  CONTESTMOVE3=[0,0,0,0]
                                  CONTESTMOVE4=[0,0,0,0]

                                  def pbAddContestMove(poke,move1=0,move2=0,move3=0,move4=0)
                                  poketochange=[0,0,0,0]
                                  poketochange[0]=move1
                                  poketochange[1]=move2
                                  poketochange[2]=move3
                                  poketochange[3]=move4
                                  case poke
                                  when 2
                                  for i in 0..3
                                  CONTESTMOVE2[i]=poketochange[i]
                                  end
                                  when 3
                                  for i in 0..3
                                  CONTESTMOVE3[i]=poketochange[i]
                                  end
                                  when 4
                                  for i in 0..3
                                  CONTESTMOVE4[i]=poketochange[i]
                                  end
                                  end
                                  end
                                  ################################################################################
                                  # nicknaming contest pokemon
                                  ################################################################################
                                  $CONTESTNAME2=""
                                  $CONTESTNAME3=""
                                  $CONTESTNAME4=""

                                  def pbChangeContestName(poke,name="")
                                  if name !="" && name.length<16
                                  case poke
                                  when 2
                                  $CONTESTNAME2=name
                                  when 3
                                  $CONTESTNAME3=name
                                  when 4
                                  $CONTESTNAME4=name
                                  end
                                  end
                                  end

                                  ################################################################################
                                  # Animation player for contest
                                  ################################################################################
                                  class PBAnimationPlayerContest
                                  attr_accessor :looping
                                  MAXSPRITES=30

                                  def initialize(animation,user,target,usersprite,targetsprite,scene=nil,ineditor=false)
                                  @animation=animation
                                  @user=user
                                  @usersprite=usersprite
                                  @targetsprite=targetsprite
                                  @userbitmap=(@usersprite && @usersprite.bitmap) ? @usersprite.bitmap : nil # not to be disposed
                                  @targetbitmap=(@targetsprite && @targetsprite.bitmap) ? @targetsprite.bitmap : nil # not to be disposed
                                  @scene=scene
                                  @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
                                  @viewport.z=99999
                                  @ineditor=ineditor
                                  @looping=false
                                  @animbitmap=nil # Animation sheet graphic
                                  @frame=-1
                                  @srcLine=nil
                                  @dstLine=nil
                                  @userOrig=getSpriteCenter(@usersprite)
                                  @targetOrig=getSpriteCenter(@targetsprite)
                                  @animsprites=[]
                                  @animsprites[0][email protected]
                                  @animsprites[1][email protected]
                                  for i in 2...MAXSPRITES
                                  @animsprites[i]=Sprite.new(@viewport)
                                  @animsprites[i].bitmap=nil
                                  @animsprites[i].visible=false
                                  end

                                  @bgColor=ColoredPlane.new(Color.new(0,0,0),@viewport)
                                  @bgColor.borderX=64 if ineditor
                                  @bgColor.borderY=64 if ineditor
                                  @bgColor.z=2
                                  @bgColor.opacity=0
                                  @bgColor.refresh
                                  @bgGraphic=AnimatedPlane.new(@viewport)
                                  @bgGraphic.setBitmap(nil)
                                  @bgGraphic.borderX=64 if ineditor
                                  @bgGraphic.borderY=64 if ineditor
                                  @bgGraphic.z=2
                                  @bgGraphic.opacity=0
                                  @bgGraphic.refresh
                                  @oldbg=[]

                                  @foColor=ColoredPlane.new(Color.new(0,0,0),@viewport)
                                  @foColor.borderX=64 if ineditor
                                  @foColor.borderY=64 if ineditor
                                  @foColor.z=38
                                  @foColor.opacity=0
                                  @foColor.refresh
                                  @foGraphic=AnimatedPlane.new(@viewport)
                                  @foGraphic.setBitmap(nil)
                                  @foGraphic.borderX=64 if ineditor
                                  @foGraphic.borderY=64 if ineditor
                                  @foGraphic.z=38
                                  @foGraphic.opacity=0
                                  @foGraphic.refresh
                                  @oldfo=[]
                                  end

                                  def dispose
                                  @animbitmap.dispose if @animbitmap
                                  for i in 2...MAXSPRITES
                                  @animsprites[i].dispose if @animsprites[i]
                                  end
                                  @bgGraphic.dispose
                                  @bgColor.dispose
                                  @foGraphic.dispose
                                  @foColor.dispose
                                  end

                                  def start
                                  @frame=0
                                  end

                                  def playing?
                                  return @frame>=0
                                  end

                                  def setLineTransform(x1,y1,x2,y2,x3,y3,x4,y4)
                                  @srcLine=[x1,y1,x2,y2]
                                  @dstLine=[x3,y3,x4,y4]
                                  end

                                  def update
                                  return if @frame<0
                                  if (@frame>>1) >= @animation.length
                                  @frame=(@looping) ? 0 : -1
                                  if @frame<0
                                  @animbitmap.dispose if @animbitmap
                                  @animbitmap=nil
                                  return
                                  end
                                  end
                                  if [email protected] || @animbitmap.disposed?
                                  @animbitmap=AnimatedBitmap.new("Graphics/Animations/"[email protected],
                                  @animation.hue).deanimate
                                  for i in 0...MAXSPRITES
                                  @animsprites[i][email protected] if @animsprites[i]
                                  end
                                  end
                                  @bgGraphic.update
                                  @bgColor.update
                                  @foGraphic.update
                                  @foColor.update
                                  if (@frame&1)==0
                                  [email protected][@frame>>1]
                                  # Make all cel sprites invisible
                                  for i in 0...MAXSPRITES
                                  @animsprites[i].visible=false if @animsprites[i]
                                  end
                                  # Set each cel sprite acoordingly
                                  for i in 0...thisframe.length
                                  cel=thisframe[i]
                                  next if !cel
                                  [email protected][i]
                                  next if !sprite
                                  # Set cel sprite's graphic
                                  if cel[AnimFrame::PATTERN]==-1
                                  [email protected]
                                  elsif cel[AnimFrame::PATTERN]==-2
                                  [email protected]
                                  else
                                  [email protected]
                                  end
                                  cel[AnimFrame::MIRROR]=1
                                  # Apply settings to the cel sprite
                                  pbSpriteSetAnimFrame(sprite,cel,@usersprite,@targetsprite)
                                  case cel[AnimFrame::FOCUS]
                                  when 1 # Focused on target
                                  sprite.x=cel[AnimFrame::X][email protected][0]-PokeBattle_SceneConstants::FOCUSTARGET_X
                                  sprite.y=cel[AnimFrame::Y][email protected][1]-PokeBattle_SceneConstants::FOCUSTARGET_Y
                                  when 2 # Focused on user
                                  sprite.x=cel[AnimFrame::X][email protected][0]-PokeBattle_SceneConstants::FOCUSUSER_X
                                  sprite.y=cel[AnimFrame::Y][email protected][1]-PokeBattle_SceneConstants::FOCUSUSER_Y
                                  when 3 # Focused on user and target
                                  if @srcLine && @dstLine
                                  point=transformPoint(
                                  @srcLine[0],@srcLine[1],@srcLine[2],@srcLine[3],
                                  @dstLine[0],@dstLine[1],@dstLine[2],@dstLine[3],
                                  sprite.x,sprite.y)
                                  sprite.x=point[0]
                                  sprite.y=point[1]
                                  end
                                  end
                                  sprite.x+=64 if @ineditor
                                  sprite.y+=64 if @ineditor
                                  end
                                  # Play timings
                                  @animation.playTiming(@frame>>1,@bgGraphic,@bgColor,@foGraphic,@foColor,@oldbg,@oldfo,@user)
                                  end
                                  @frame+=1
                                  end
                                  end
                                  __________________
                                  Looking for a team to help me finish Pokemon Green Remix

                                  DM please
                                  Reply With Quote
                                    #67    
                                  Old June 20th, 2015 (10:17 AM).
                                  Richard PT's Avatar
                                  Richard PT Richard PT is offline
                                     
                                    Join Date: Aug 2014
                                    Location: Portugal
                                    Gender: Male
                                    Nature: Calm
                                    Posts: 120
                                    When i call an event to mix berries i've got this error.

                                    __________________
                                    Reply With Quote
                                      #68    
                                    Old June 22nd, 2015 (8:05 AM).
                                    FoxySeta's Avatar
                                    FoxySeta FoxySeta is offline
                                    (Trainer)
                                       
                                      Join Date: Sep 2014
                                      Location: Lugo (RA) (IT)
                                      Gender: Male
                                      Nature: Quirky
                                      Posts: 11
                                      Another question: where are moves description from?
                                      Reply With Quote
                                        #69    
                                      Old June 22nd, 2015 (9:46 AM).
                                      Zeak6464's Avatar
                                      Zeak6464 Zeak6464 is offline
                                      Zeak #3205 - Discord
                                         
                                        Join Date: Mar 2013
                                        Location: USA
                                        Age: 25
                                        Gender: Male
                                        Nature: Calm
                                        Posts: 550
                                        Quote:
                                        Originally Posted by FoxySeta View Post
                                        Another question: where are moves description from?
                                        PBS "ContestMoves" file , that is in the downloads
                                        __________________
                                        Looking for a team to help me finish Pokemon Green Remix

                                        DM please
                                        Reply With Quote
                                          #70    
                                        Old June 25th, 2015 (12:09 PM).
                                        FoxySeta's Avatar
                                        FoxySeta FoxySeta is offline
                                        (Trainer)
                                           
                                          Join Date: Sep 2014
                                          Location: Lugo (RA) (IT)
                                          Gender: Male
                                          Nature: Quirky
                                          Posts: 11
                                          Quote:
                                          Originally Posted by Zeak6464 View Post
                                          PBS "ContestMoves" file , that is in the downloads
                                          Sorry, I mean "from which game". I guess Megahorn, for example, had another effect.
                                          And can someone answer to my other post?
                                          Reply With Quote
                                            #71    
                                          Old August 25th, 2015 (12:56 PM).
                                          Diego San Diego San is offline
                                             
                                            Join Date: Aug 2015
                                            Posts: 1
                                            Hi, that's my problem. I want to change the Pokémon in contest. I think is the script in more than one line but I'm not sure and don't know the solution. Thanks.


                                            Exception: RuntimeError

                                            Message: Script error within event 21, map 89 (Ciudad Mentada):

                                            Exception: SyntaxError

                                            Message: (eval):4:in `pbExecuteScript'compile error
                                            (eval):3: syntax error
                                            (50,PBSpecies::FARFETCHD,20,PBSpecies::SQUI
                                            ^
                                            (eval):3: syntax error
                                            (50,PBSpecies::FARFETCHD,20,PBSpecies::SQUI
                                            ^
                                            (eval):4: syntax error
                                            RTLE,20,PBSpecies::HITMONTOP,20,1)
                                            ^
                                            (eval):4: syntax error
                                            RTLE,20,PBSpecies::HITMONTOP,20,1)
                                            ^

                                            ***Line '(50,PBSpecies::FARFETCHD,20,PBSpecies::SQUI' shouldn't begin with '('. Try

                                            putting '(' at the end of the previous line instead,

                                            or using Extendtext.

                                            ***Full script:

                                            pbChangeContestName(2,"Farfi")
                                            pbContest
                                            (50,PBSpecies::FARFETCHD,20,PBSpecies::SQUI
                                            RTLE,20,PBSpecies::HITMONTOP,20,1)




                                            Interpreter:276:in `pbExecuteScript'

                                            Interpreter:1600:in `command_355'

                                            Interpreter:494:in `execute_command'

                                            Interpreter:193:in `update'

                                            Interpreter:106:in `loop'

                                            Interpreter:198:in `update'

                                            Scene_Map:103:in `update'

                                            Scene_Map:101:in `loop'

                                            Scene_Map:114:in `update'

                                            Scene_Map:68:in `main'
                                            Reply With Quote
                                              #72    
                                            Old August 30th, 2015 (1:15 AM).
                                            bimbimthiensu bimbimthiensu is offline
                                               
                                              Join Date: Jul 2013
                                              Gender: Male
                                              Posts: 46
                                              hi @mej71, how can i add some more move in contest moves? i know that i need to add in contestmoves.txt but i dont know the red number mean
                                              Code:
                                              460,PSYBEAM,Psybeam,Beauty,3,0,024,"Scrambles the order of appeals on the next turn."
                                              and i have a bug, Berry Mixer doesn't work (like @Richard PT's bug)
                                              Reply With Quote
                                                #73    
                                              Old September 11th, 2015 (3:36 AM).
                                              mewlover22's Avatar
                                              mewlover22 mewlover22 is offline
                                              Pokemon Creator
                                                 
                                                Join Date: Oct 2008
                                                Location: South Carolina
                                                Gender: Male
                                                Nature: Quiet
                                                Posts: 346
                                                so could we make this work for version 14 all parts i really love this script and would love to have the player have the option to do this at any point in time by going to the hall in each city i put it in and participate in it. Also can we set up more than just a beginner style contest like ruby did?
                                                __________________
                                                This signature has been disabled.
                                                Signature exceeds 600px width limit.
                                                Please review and fix the issues by reading the signature rules.

                                                You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

                                                Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
                                                Reply With Quote
                                                  #74    
                                                Old September 12th, 2015 (2:31 AM).
                                                Sharazel's Avatar
                                                Sharazel Sharazel is offline
                                                   
                                                  Join Date: May 2015
                                                  Gender: Male
                                                  Posts: 65
                                                  I get this Error:
                                                  http://i.imgur.com/YQwiixG.png
                                                  Reply With Quote
                                                    #75    
                                                  Old October 3rd, 2015 (11:39 PM).
                                                  ISNorden's Avatar
                                                  ISNorden ISNorden is offline
                                                  Teddiursa
                                                     
                                                    Join Date: Feb 2013
                                                    Location: Madison, Wisconsin, USA
                                                    Gender: Female
                                                    Nature: Gentle
                                                    Posts: 160
                                                    Is this script compatible with the Generation VI update patch? I'd love to have ORAS-style contests in a fangame.
                                                    __________________
                                                    ========================

                                                    Ingeborg S. Nordén

                                                    " Coming this fall to Jubilife TV: Lost Beyond Space!" :P
                                                    Reply With Quote
                                                    Reply

                                                    Quick Reply

                                                    Join the conversation!

                                                    Create an account to post a reply in this thread, participate in other discussions, and more!

                                                    Create a PokéCommunity Account
                                                    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

                                                    Forum Jump


                                                    All times are GMT -8. The time now is 5:58 AM.