Advertisement
mej71

Contest Script

Oct 8th, 2014
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 105.05 KB | None | 0 0
  1. class PokeContestScene
  2.   attr_reader :name
  3.   attr_accessor :selected
  4.   attr_reader  :hearts
  5.  
  6.  
  7.   def initialize
  8.     @sprites={}
  9.     @heartsprites={}
  10.     @@won=false
  11.     @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  12.     @viewport.z=99999
  13.     @viewport2=Viewport.new(0,0,Graphics.width,Graphics.height)
  14.     @viewport2.z=99999+2
  15.     @sprites["background"]=IconSprite.new(0,0,@viewport)
  16.     @sprites["background"].setBitmap("Graphics/Pictures/Contest/contestbg")
  17.   end
  18.    
  19.   #CONTESTCOMBOS are defined in the bottom of this script
  20.   def pbCheckforCombos
  21.     case @currentpoke
  22.     when @pkmn1
  23.       oldmove=@pkmn1lastmove
  24.     when @pkmn2
  25.       oldmove=@pkmn2lastmove
  26.     when @pkmn3
  27.       oldmove=@pkmn3lastmove
  28.     when @pkmn4
  29.       oldmove=@pkmn4lastmove
  30.     end
  31.     for j in 0..CONTESTCOMBOS.length-1
  32.       if oldmove==CONTESTCOMBOS[j][0]
  33.         for i in 1..CONTESTCOMBOS[j].length-1
  34.          if @currentmovename==CONTESTCOMBOS[j][i]
  35.           return true
  36.          end
  37.         end
  38.       end
  39.     end
  40.    return false
  41.   end
  42.  
  43.   def update
  44.     pbUpdateSpriteHash(@sprites)
  45.   end
  46.  
  47.   def pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
  48.     pbBGMPlay("021-Field04")  #Change this for different music
  49.     @contestover=false  #ends when set to true
  50.     @difficulty=difficulty
  51.     @ribbonnum=ribbonnum #ribbon number given if won
  52.     case $game_variables[35]
  53.     when 1
  54.       @contestType="Cool"
  55.     when 2
  56.       @contestType="Beauty"
  57.     when 3
  58.       @contestType="Cute"
  59.     when 4
  60.       @contestType="Smart"
  61.     when 5
  62.       @contestType="Tough"
  63.     else
  64.       @contestType="Cool"
  65.     end
  66.     @pkmn1=$Trainer.party[$game_variables[36]]
  67.     @pkmn2=PokeBattle_Pokemon.new(opponent1,opponent1level,$Trainer)
  68.     @pkmn3=PokeBattle_Pokemon.new(opponent2,opponent2level,$Trainer)
  69.     @pkmn4=PokeBattle_Pokemon.new(opponent3,opponent3level,$Trainer)
  70.     #teach opponent pokemon new moves if defined
  71.     for i in 0...CONTESTMOVE2.length
  72.          @pkmn2.pbLearnMove(CONTESTMOVE2[i]) if CONTESTMOVE2[i]!=0
  73.     end
  74.     for i in 0...CONTESTMOVE3.length
  75.          @pkmn3.pbLearnMove(CONTESTMOVE3[i]) if CONTESTMOVE3[i]!=0
  76.     end
  77.     for i in 0...CONTESTMOVE4.length
  78.          @pkmn4.pbLearnMove(CONTESTMOVE4[i]) if CONTESTMOVE4[i]!=0
  79.     end  
  80.     #nicknames for contest pokemon
  81.     @pkmn2.name=$CONTESTNAME2 if $CONTESTNAME2 !=""
  82.     @pkmn3.name=$CONTESTNAME3 if $CONTESTNAME3 !=""
  83.     @pkmn4.name=$CONTESTNAME4 if $CONTESTNAME4 !=""
  84.     @pkmn1total=0
  85.     @pkmn2total=0
  86.     @pkmn3total=0
  87.     @pkmn4total=0
  88.     @pkmn1DoubleNext=false
  89.     @pkmn2DoubleNext=false
  90.     @pkmn3DoubleNext=false
  91.     @pkmn4DoubleNext=false
  92.     @pkmn1MissTurn=false
  93.     @pkmn2MissTurn=false
  94.     @pkmn3MissTurn=false
  95.     @pkmn4MissTurn=false
  96.     @pkmn1nomoremoves=false
  97.     @pkmn2nomoremoves=false
  98.     @pkmn3nomoremoves=false
  99.     @pkmn4nomoremoves=false
  100.     @applause=0
  101.     @pkmn1stars=0
  102.     @pkmn2stars=0
  103.     @pkmn3stars=0
  104.     @pkmn4stars=0
  105.     @pkmn1hearts=0
  106.     @pkmn2hearts=0
  107.     @pkmn3hearts=0
  108.     @pkmn4hearts=0
  109.     @stars=[@pkmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
  110.     pbPreliminaryScene #extra points for scarves, points gained by pokeblocks and such done here
  111.     #the "preliminary judging" seen before this starts is just for show, it doesn't do anything then
  112.     pbResetContestMoveEffects
  113.     pbResetHearts
  114.     @round=0
  115.     if !($DEBUG && Input.press?(Input::CTRL)) #Skip all rounds if pressing Control in Debug mode
  116.       @round=1
  117.       pbTurn(@round)
  118.       if !($DEBUG && Input.press?(Input::CTRL))
  119.        @round=2
  120.        pbTurn(@round)
  121.        @round=3
  122.        pbTurn(@round)
  123.        @round=4
  124.        pbTurn(@round)
  125.        @round=5
  126.        pbTurn(@round)
  127.      else
  128.        pbResetHearts
  129.        pbDebugTotals(1)
  130.       end
  131.     else
  132.       @prelim1+=90
  133.       pbResetHearts
  134.       pbDebugTotals(6)
  135.     end
  136.     pbDisposeSprite(@sprites,"overlay2") #clear overlay to prep for end scene
  137.     #  End scene
  138.     @sprites["background"]=IconSprite.new(0,0,@viewport)
  139.     @sprites["background"].setBitmap("Graphics/Pictures/Contest/contestbg")
  140.     pbResultsScene
  141.     $game_variables[35]=0  #reset variables
  142.     $game_variables[36]=0
  143.     @contestover=true  #allows scene to exit loop and end
  144.   end
  145.  
  146. ###############################################################################
  147. #       Main round processing function
  148. ###############################################################################
  149.   def pbTurn(turnnumber)
  150.     Graphics.update
  151.     @atself=false
  152.     @priorhearts=0
  153.     if @round==1
  154.     @sprites["Judge"]=IconSprite.new(0,0,@viewport)
  155.     @sprites["Judge"].setBitmap("Graphics/Characters/trainer017")
  156.     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)
  157.     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)
  158.     pbDisposeSprite(@sprites,"Judge")
  159.     sleep(1.0/3.0)
  160.     Graphics.update      
  161.     end
  162.       if @round==1                   #
  163.         pbFindFastestOrderRanking    #
  164.       else                           #determine order
  165.         pbOrder                      #
  166.       end                            #
  167.     pbResetContestMoveEffects
  168.     pbDrawText
  169.     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"
  170.     @sprites["Round"]=IconSprite.new(0,0,@viewport)
  171.     @sprites["Round"].setBitmap(roundfile)
  172.     sleep(1.0/7.0)
  173.     Graphics.update
  174.     roundupdown=0
  175.     for i in 0...9
  176.       if roundupdown==0 or roundupdown==1 or roundupdown==4 or roundupdown==5 or roundupdown==8 or roundupdown==9
  177.     @sprites["Round"].y+=6
  178.      else
  179.     @sprites["Round"].y-=6
  180.      end
  181.     roundupdown+=1
  182.     Graphics.update
  183.     sleep(1.0/7.0)
  184.     end
  185.     sleep(1)
  186.     pbDisposeSprite(@sprites,"Round")
  187.     pbMoveButtons
  188.     @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
  189.     pbSetSystemFont(@sprites["overlay"].bitmap)
  190.     pbDisplayFastest
  191.     @sprites["opponent"]=IconSprite.new(50,30,@viewport)    #
  192.     @sprites["opponent"].setBitmap("Graphics/Battler/000")  #invisible sprite to serve as target for animations
  193.     @sprites["opponent"].visible=false                      #
  194.     Graphics.update
  195.     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)
  196.     @currentpos=1
  197.     @currentpoke=@pokeorder[0]
  198.     if @currentpoke==@pkmn1                  #
  199.     i=@moveselection                         #
  200.     else                                   #Determine which move to use
  201.     i=pbAI(@pokeorder[0],@difficulty)      # AI for opponents
  202.     end                                      #
  203.     movedata=PBMoveData.new(@pokeorder[0].moves[i].id)
  204.     movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
  205.     @currentmovename=PBMoves.getName(@pokeorder[0].moves[i].id)
  206.        sleep(1)
  207.     for i in 1..PBContestMoves.maxValue    #
  208.     name=PBContestMoves.getName(i)         #
  209.     if @currentmovename==name              # Match the pokemon's move with the equivalent from contestmoves.txt
  210.       @currentmove=getID(PBContestMoves,i) #
  211.       @currentmove1=getID(PBMoves,i)       # Get actual ID to display proper move animation
  212.     end
  213.   end
  214.   (movedata.target==PBTargets::User)? @atself=true :@atself=false
  215.   contestmovedata=PBContestMoveData.new(@currentmove)  #Find the moves contest data
  216.     @currenthearts=contestmovedata.hearts
  217.     moveType=contestmovedata.contestType
  218.     pbmoveType(moveType)
  219.     if pbNoMore==false  #skip the move processing if nomore moves is true
  220.     if pbMissTurn==false     #skip move processing if it misses this turn
  221.       if pbDoubleNext==true  #check for double hearts
  222.         @currenthearts*=2
  223.         pbReverseDoubleNext
  224.       end
  225.     if @nervous[@currentpos-1]==true
  226.     Kernel.pbCustomMessage(_INTL("\\\l[3]{1} is nervous.",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  227.     if rand(100)<30                                                   #check for nervousness, 30% chance
  228.       Kernel.pbCustomMessage(_INTL("\\\l[3]{1} was too nervous to move!",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  229.     else
  230.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[0].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  231.     pbAnimation(@currentmove1,0,1,hitnum=0)
  232.     end
  233.     else
  234.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[0].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  235.     pbAnimation(@currentmove1,0,1,hitnum=0)
  236.    end
  237. else
  238.   pbReverseMissTurn   #change miss turn variable back after missing turn
  239. end
  240. end
  241.     pbFunctionsAdjustHearts  #
  242.     pbDisplayAddingPositiveHearts
  243.     if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
  244.       @currenthearts-=1
  245.       Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  246.       pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
  247.       pbDecreaseHearts(@currentpoke,@currentpos,selfjam="notnil")
  248.     end
  249.     if @round !=1 && pbCheckforCombos==true
  250.      @currenthearts=5
  251.      Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  252.      pbDisplayAddingPositiveHearts
  253.      pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
  254.     end
  255.     pbAssignLastMove
  256.     @lastmoveType=@moveType
  257.     pbCrowd
  258.     Graphics.update
  259.     sleep(1.0/10.0)
  260.     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)
  261.     sleep(1.0/10.0)
  262.     pbDisposeSprite(@sprites,"pokemon1")
  263.     Graphics.update
  264.     sleep(1.0/10.0)
  265.     Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  266.     pbDisplaySecondFastest
  267.     Graphics.update
  268.     sleep(1.0/10.0)
  269.     @currentpos=2
  270.     @currentpoke=@pokeorder[1]
  271.     if @currentpoke==@pkmn1
  272.     i=@moveselection
  273.     else
  274.     i=pbAI(@pokeorder[1],@difficulty)
  275.     end
  276.     movedata=PBMoveData.new(@pokeorder[1].moves[i].id)
  277.     movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
  278.     @currentmovename=PBMoves.getName(@pokeorder[1].moves[i].id)
  279.        sleep(1)
  280.     for i in 1..PBContestMoves.maxValue
  281.       name=PBContestMoves.getName(i)
  282.       if @currentmovename==name
  283.         @currentmove=getID(PBContestMoves,i)
  284.         @currentmove1=getID(PBMoves,i)
  285.       end
  286.     end
  287.     (movedata.target==PBTargets::User)? @atself=true :@atself=false
  288.     contestmovedata=PBContestMoveData.new(@currentmove)
  289.     @currenthearts=contestmovedata.hearts
  290.     moveType=contestmovedata.contestType
  291.     pbmoveType(moveType)
  292.  if pbNoMore==false  #skip the move processing if nomore moves is true
  293.     if pbMissTurn==false     #skip move processing if it misses this turn
  294.       if pbDoubleNext==true  #check for double hearts
  295.         @currenthearts*=2
  296.         pbReverseDoubleNext
  297.       end
  298.     if @nervous[@currentpos-1]==true
  299.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  300.     if rand(100)<30                                                   #check for nervousness, 30% chance
  301.       Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[1].name))
  302.     else
  303.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[1].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  304.     pbAnimation(@currentmove1,0,1,hitnum=0)
  305.     end
  306.     else
  307.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[1].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  308.     pbAnimation(@currentmove1,0,1,hitnum=0)
  309.    end
  310. else
  311.   pbReverseMissTurn   #change miss turn variable back after missing turn
  312. end
  313. end
  314.     pbFunctionsAdjustHearts  
  315.     pbDisplayAddingPositiveHearts
  316.     if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
  317.       @currenthearts-=1
  318.       Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  319.       pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
  320.       pbDecreaseHearts(@currentpoke,@currentpos,selfjam="notnil")
  321.     end
  322.     if @round !=1 && pbCheckforCombos==true
  323.      @currenthearts=5
  324.      Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  325.      pbDisplayAddingPositiveHearts
  326.      pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
  327.     end
  328.     pbAssignLastMove
  329.     @lastmoveType=@moveType
  330.     pbCrowd
  331.     Graphics.update
  332.     sleep(1.0/10.0)
  333.     pbDisposeSprite(@sprites,"pokemon2")
  334.     Graphics.update
  335.     sleep(1.0/10.0)
  336.     Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  337.     pbDisplayThirdFastest
  338.     Graphics.update
  339.     sleep(1.0/10.0)
  340.     @currentpos=3
  341.     @currentpoke=@pokeorder[2]
  342.     if @currentpoke==@pkmn1
  343.     i=@moveselection
  344.     else
  345.     i=pbAI(@pokeorder[2],@difficulty)
  346.     end
  347.     movedata=PBMoveData.new(@pokeorder[2].moves[i].id)
  348.     movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
  349.     @currentmovename=PBMoves.getName(@pokeorder[2].moves[i].id)
  350.        sleep(1)
  351.     for i in 1..PBContestMoves.maxValue
  352.     name=PBContestMoves.getName(i)
  353.     if @currentmovename==name
  354.       @currentmove=getID(PBContestMoves,i)
  355.       @currentmove1=getID(PBMoves,i)
  356.     end
  357.   end
  358.   (movedata.target==PBTargets::User)? @atself=true :@atself=false
  359.   contestmovedata=PBContestMoveData.new(@currentmove)
  360.     @currenthearts=contestmovedata.hearts
  361.     moveType=contestmovedata.contestType
  362.     pbmoveType(moveType)
  363.     if pbNoMore==false  #skip the move processing if nomore moves is true
  364.     if pbMissTurn==false     #skip move processing if it misses this turn
  365.       if pbDoubleNext==true  #check for double hearts
  366.         @currenthearts*=2
  367.         pbReverseDoubleNext
  368.       end
  369.     if @nervous[@currentpos-1]==true
  370.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  371.     if rand(100)<30                                                   #check for nervousness, 30% chance
  372.       Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  373.     else
  374.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[2].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  375.     pbAnimation(@currentmove1,0,1,hitnum=0)
  376.     end
  377.     else
  378.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[2].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  379.     pbAnimation(@currentmove1,0,1,hitnum=0)
  380.    end
  381. else
  382.   pbReverseMissTurn   #change miss turn variable back after missing turn
  383. end
  384. end
  385.     pbFunctionsAdjustHearts  #
  386.     pbDisplayAddingPositiveHearts
  387.     if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
  388.       @currenthearts-=1
  389.       Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  390.       pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
  391.       pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,selfjam="notnil")
  392.     end
  393.     if @round !=1 && pbCheckforCombos==true
  394.      @currenthearts=5
  395.      Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  396.      pbDisplayAddingPositiveHearts
  397.      pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
  398.     end
  399.     pbAssignLastMove
  400.     @lastmoveType=@moveType
  401.     pbCrowd
  402.     Graphics.update
  403.     sleep(1.0/10.0)
  404.     pbDisposeSprite(@sprites,"pokemon3")
  405.     Graphics.update
  406.     sleep(1.0/10.0)
  407.     Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  408.     pbDisplayFourthFastest
  409.     Graphics.update
  410.     sleep(1.0/10.0)
  411.     @currentpos=4
  412.     @currentpoke=@pokeorder[3]
  413.     if @currentpoke==@pkmn1
  414.     i=@moveselection
  415.     else
  416.     i=pbAI(@pokeorder[3],@difficulty)
  417.     end
  418.     movedata=PBMoveData.new(@pokeorder[3].moves[i].id)
  419.     movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
  420.     @currentmovename=PBMoves.getName(@pokeorder[3].moves[i].id)
  421.        sleep(1)
  422.     for i in 1..PBContestMoves.maxValue
  423.     name=PBContestMoves.getName(i)
  424.     if @currentmovename==name
  425.       @currentmove=getID(PBContestMoves,i)
  426.       @currentmove1=getID(PBMoves,i)
  427.     end
  428.   end
  429.   (movedata.target==PBTargets::User)? @atself=true :@atself=false
  430.   contestmovedata=PBContestMoveData.new(@currentmove)
  431.     @currenthearts=contestmovedata.hearts
  432.     moveType=contestmovedata.contestType
  433.     pbmoveType(moveType)
  434.    if pbNoMore==false  #skip the move processing if nomore moves is true
  435.     if pbMissTurn==false     #skip move processing if it misses this turn
  436.       if pbDoubleNext==true  #check for double hearts
  437.         @currenthearts*=2
  438.         pbReverseDoubleNext
  439.       end
  440.     if @nervous[@currentpos-1]==true
  441.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  442.     if rand(100)<30                                                   #check for nervousness, 30% chance
  443.       Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  444.     else
  445.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[3].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  446.     pbAnimation(@currentmove1,0,1,hitnum=0)
  447.     end
  448.     else
  449.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[3].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  450.     pbAnimation(@currentmove1,0,1,hitnum=0)
  451.    end
  452. else
  453.   pbReverseMissTurn   #change miss turn variable back after missing turn
  454. end
  455. end
  456.     pbFunctionsAdjustHearts  #
  457.     pbDisplayAddingPositiveHearts
  458.     if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
  459.       @currenthearts-=1
  460.       Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  461.       pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
  462.       pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,selfjam="notnil")
  463.     end
  464.     if @round !=1 && pbCheckforCombos==true
  465.      @currenthearts=5
  466.      Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  467.      pbDisplayAddingPositiveHearts
  468.      pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
  469.     end
  470.     pbAssignLastMove
  471.     @lastmoveType=@moveType
  472.     pbCrowd
  473.     Graphics.update
  474.     sleep(1.0/10.0)
  475.     pbDisposeSprite(@sprites,"pokemon4")
  476.     pbDisposeSprite(@sprites,"opponent")
  477.     pbResetHearts
  478.     Graphics.update
  479.   end
  480.  
  481. ###############################################################################
  482. #  Misc.  Functions
  483. ###############################################################################
  484.   def pbAssignLastMove
  485.     case @currentpoke
  486.     when @pkmn1
  487.       @pkmn1lastmove=@currentmovename
  488.     when @pkmn2
  489.      @pkmn2lastmove=@currentmovename
  490.     when @pkmn3
  491.       @pkmn3lastmove=@currentmovename
  492.     else
  493.       @pkmn4lastmove=@currentmovename
  494.     end
  495.   end
  496.  
  497.   def pbCheckLast
  498.     case @currentpoke
  499.     when @pkmn1
  500.       if @pkmn1lastmove
  501.       if @currentmovename==@pkmn1lastmove
  502.         return true
  503.       else
  504.         return false
  505.       end
  506.       end
  507.     when @pkmn2
  508.       if @pkmn2lastmove
  509.       if @currentmovename==@pkmn2lastmove
  510.         return true
  511.       else
  512.         return false
  513.       end
  514.       end
  515.     when @pkmn3
  516.       if @pkmn3lastmove
  517.       if @currentmovename==@pkmn3lastmove
  518.         return true
  519.       else
  520.         return false
  521.       end
  522.     end
  523.     when @pkmn4
  524.       if @pkmn4lastmove
  525.       if @currentmovename==@pkmn4lastmove
  526.         return true
  527.       else
  528.         return false
  529.       end
  530.       end
  531.     end
  532.   end
  533.  
  534.   def pbmoveType(moveType)
  535.     case moveType
  536.     when 0
  537.       @moveType="Cool"
  538.     when 1
  539.       @moveType="Beauty"
  540.     when 2
  541.       @moveType="Cute"
  542.     when 3
  543.       @moveType="Smart"
  544.     when 4
  545.       @moveType="Tough"
  546.     end
  547.   end
  548.  
  549.   def pbDrawText
  550.     @sprites["overlay2"].bitmap.clear if @sprites["overlay2"]
  551.     #change graphic indicating what position the player's pokemon is at
  552.     if !@sprites["playerspokebg"]
  553.       @sprites["playerspokebg"]=IconSprite.new(347,96,@viewport)
  554.       @sprites["playerspokebg"].setBitmap("Graphics/Pictures/Contest/playerspoke")
  555.     end
  556.   for i in 0..3
  557.     if @pokeorder[i]==@pkmn1
  558.       @sprites["playerspokebg"].y=96*i
  559.     end
  560.   end
  561.     @sprites["overlay2"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport) if !@sprites["overlay2"]
  562.     pbSetSystemFont(@sprites["overlay2"].bitmap)
  563.     overlay=@sprites["overlay2"].bitmap
  564.     overlay.clear
  565.     pokeone=_INTL("{1}",@pokeorder[0].name)
  566.     poketwo=_INTL("{1}",@pokeorder[1].name)
  567.     pokethree=_INTL("{1}",@pokeorder[2].name)
  568.     pokefour=_INTL("{1}",@pokeorder[3].name)
  569.     baseColor=Color.new(72,72,72)
  570.     shadowColor=Color.new(160,160,160)
  571.     textPositions=[
  572.        [pokeone,353,5,false,baseColor,shadowColor],
  573.        [poketwo,353,100,false,baseColor,shadowColor],
  574.        [pokethree,353,195,false,baseColor,shadowColor],
  575.        [pokefour,353,290,false,baseColor,shadowColor],
  576.     ]
  577.     pbDrawTextPositions(overlay,textPositions)
  578.   end
  579.  
  580.  
  581. def pbNoMore  #checks if pokemon can use moves
  582.   case @currentpoke
  583.    when @pkmn1
  584.      if @pkmn1nomoremoves==true
  585.        return true
  586.      else
  587.        return false
  588.      end
  589.     when @pkmn2
  590.       if @pkmn2nomoremoves==true
  591.         return true
  592.       else
  593.         return false
  594.       end
  595.     when @pkmn3
  596.        if @pkmn3nomoremoves==true
  597.          return true
  598.        else
  599.          return false
  600.        end
  601.     when @pkmn4
  602.        if @pkmn4nomoremoves==true
  603.          return true
  604.        else
  605.          return false
  606.        end
  607.      else
  608.        return false
  609.      end
  610.    end
  611.    
  612. def pbMissTurn  #Checks if pokemon misses this turn
  613.   case @currentpoke
  614.    when @pkmn1
  615.      if @pkmn1MissTurn==true
  616.        return true
  617.      else
  618.        return false
  619.      end
  620.     when @pkmn2
  621.       if @pkmn2MissTurn==true
  622.         return true
  623.       else
  624.         return false
  625.       end
  626.     when @pkmn3
  627.        if @pkmn3MissTurn==true
  628.          return true
  629.        else
  630.          return false
  631.        end
  632.     when @pkmn4
  633.        if @pkmn4MissTurn==true
  634.          return true
  635.        else
  636.          return false
  637.        end
  638.      else
  639.        return false
  640.      end
  641.    end
  642.    
  643. def pbDoubleNext  #Check if it should double hearts
  644.   case @currentpoke
  645.    when @pkmn1
  646.      if @pkmn1DoubleNext==true
  647.        return true
  648.      else
  649.        return false
  650.      end
  651.     when @pkmn2
  652.       if @pkmn2DoubleNext==true
  653.         return true
  654.       else
  655.         return false
  656.       end
  657.     when @pkmn3
  658.        if @pkmn3DoubleNext==true
  659.          return true
  660.        else
  661.          return false
  662.        end
  663.     when @pkmn4
  664.        if @pkmn4DoubleNext==true
  665.          return true
  666.        else
  667.          return false
  668.        end
  669.      else
  670.        return false
  671.      end
  672.    end
  673.  
  674.   def pbSetNoMoreMoves
  675.    case @currentpoke
  676.       when @pkmn1
  677.         @pkmn1nomoremoves=true
  678.       when @pkmn2
  679.         @pkmn2nomoremoves=true
  680.       when @pkmn3
  681.         @pkmn3nomoremoves=true
  682.       when @pkmn4
  683.         @pkmn4nomoremoves=true
  684.       end
  685.     end
  686.    
  687.   def pbSetMissTurn
  688.     case @currentpoke
  689.       when @pkmn1
  690.         @pkmn1MissTurn=true
  691.       when @pkmn2
  692.         @pkmn2MissTurn=true
  693.       when @pkmn3
  694.         @pkmn3MissTurn=true
  695.       when @pkmn4
  696.         @pkmn4MissTurn=true
  697.       end
  698.   end  
  699.    
  700.   def pbSetDoubleNext
  701.      case @currentpoke
  702.       when @pkmn1
  703.         @pkmn1DoubleNext=true
  704.       when @pkmn2
  705.         @pkmn2DoubleNext=true
  706.       when @pkmn3
  707.         @pkmn3DoubleNext=true
  708.       when @pkmn4
  709.         @pkmn4DoubleNext=true
  710.       end
  711.   end
  712.  
  713.   def pbReverseMissTurn
  714.     case @currentpoke
  715.       when @pkmn1
  716.         @pkmn1MissTurn=false
  717.       when @pkmn2
  718.         @pkmn2MissTurn=false
  719.       when @pkmn3
  720.         @pkmn3MissTurn=false
  721.       when @pkmn4
  722.         @pkmn4MissTurn=false
  723.       end
  724.   end
  725.  
  726.   def pbReverseDoubleNext
  727.     case @currentpoke
  728.       when @pkmn1
  729.         @pkmn1DoubleNext=false
  730.       when @pkmn2
  731.         @pkmn2DoubleNext=false
  732.       when @pkmn3
  733.         @pkmn3DoubleNext=false
  734.       when @pkmn4
  735.         @pkmn4DoubleNext=false
  736.       end
  737.     end
  738.    
  739.    
  740.    
  741. ###############################################################################
  742. #  Heart Graphic Functions
  743. ###############################################################################
  744. def pbDisplayAddingPositiveHearts
  745.   case @currentpoke
  746.     when @pkmn1
  747.          for i in 0...@currenthearts
  748.            @pkmn1hearts+=1
  749.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn1hearts)if @pkmn1hearts<21
  750.         Graphics.update
  751.         sleep(1.0/7.0)
  752.         @heartsprites["firstpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
  753.         @heartsprites["firstpokehearts"].setBitmap(heartfile)
  754.       end
  755.       @priorhearts=@pkmn1hearts
  756.    when @pkmn2
  757.         for i in 0...@currenthearts
  758.           @pkmn2hearts+=1
  759.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn2hearts)if @pkmn2hearts<21
  760.         Graphics.update
  761.         sleep(1.0/7.0)
  762.         @heartsprites["secondpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
  763.         @heartsprites["secondpokehearts"].setBitmap(heartfile)
  764.       end
  765.       @priorhearts=@pkmn2hearts
  766.   when @pkmn3
  767.         for i in 0...@currenthearts
  768.           @pkmn3hearts+=1
  769.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn3hearts)if @pkmn3hearts<21
  770.         Graphics.update
  771.         sleep(1.0/7.0)
  772.         @heartsprites["thirdpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
  773.         @heartsprites["thirdpokehearts"].setBitmap(heartfile)
  774.       end
  775.       @priorhearts=@pkmn3hearts
  776.   when @pkmn4
  777.         for i in 0...@currenthearts
  778.           @pkmn4hearts+=1
  779.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn4hearts)if @pkmn4hearts<21
  780.         Graphics.update
  781.         sleep(1.0/7.0)
  782.         @heartsprites["fourthpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
  783.         @heartsprites["fourthpokehearts"].setBitmap(heartfile)
  784.       end
  785.       @priorhearts=@pkmn4hearts
  786.    end
  787. end
  788.  
  789. def pbDecreaseHearts(target,position,selfjam=nil)
  790.   if selfjam==nil
  791.    if @currentjam==1
  792.       Kernel.pbCustomMessage(_INTL("\\l[3]{1} looked down out of distraction!",target.name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  793.    else
  794.       Kernel.pbCustomMessage(_INTL("\\l[3]{1} couldn't help leaping up!",target.name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  795.    end
  796.   end
  797.   case target
  798.     when @pkmn1
  799.       @pkmn1jam*=2 if @easilystartled[position-1]==true
  800.         for i in 0...@pkmn1jam
  801.           @pkmn1hearts -= 1
  802.              if @pkmn1hearts == 0
  803.                pbDisposeSprite(@heartsprites,"firstpokehearts")
  804.                @heartsprites["firstpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
  805.              end
  806.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn1hearts) if @pkmn1hearts >= 0 && @pkmn1hearts<21
  807.           heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn1hearts.abs) if @pkmn1hearts < 0 && @pkmn1hearts>-21
  808.           @heartsprites["firstpokehearts"].setBitmap(heartfile)
  809.           sleep(1.0/7.0)
  810.           Graphics.update
  811.         end
  812.         @priorhearts=@pkmn1hearts
  813.       when @pkmn2
  814.        @pkmn2jam*=2 if @easilystartled[position-1]==true
  815.         for i in 0...@pkmn2jam
  816.           @pkmn2hearts -= 1
  817.              if @pkmn2hearts == 0
  818.                pbDisposeSprite(@heartsprites,"secondpokehearts")
  819.                @heartsprites["secondpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
  820.              end
  821.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn2hearts) if @pkmn2hearts >= 0 && @pkmn2hearts<21
  822.           heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn2hearts.abs) if @pkmn2hearts < 0 && @pkmn2hearts>-21
  823.           @heartsprites["secondpokehearts"].setBitmap(heartfile)
  824.           sleep(1.0/7.0)
  825.           Graphics.update
  826.         end
  827.         @priorhearts=@pkmn2hearts
  828.      when @pkmn3
  829.       @pkmn3jam*=2 if @easilystartled[position-1]==true
  830.         for i in 0...@pkmn3jam
  831.           @pkmn3hearts -= 1
  832.              if @pkmn3hearts == 0
  833.                pbDisposeSprite(@heartsprites,"thirdpokehearts")
  834.                @heartsprites["thirdpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
  835.              end
  836.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn3hearts) if @pkmn3hearts >= 0 && @pkmn3hearts<21
  837.           heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn3hearts.abs) if @pkmn3hearts < 0 && @pkmn3hearts>-21
  838.           @heartsprites["thirdpokehearts"].setBitmap(heartfile)
  839.           sleep(1.0/7.0)
  840.           Graphics.update
  841.         end
  842.         @priorhearts=@pkmn3hearts
  843.       when @pkmn4
  844.        @pkmn4jam*=2 if @easilystartled[position-1]==true
  845.         for i in 0...@pkmn4jam
  846.           @pkmn4hearts -= 1
  847.              if @pkmn4hearts == 0
  848.                pbDisposeSprite(@heartsprites,"fourthpokehearts")
  849.                @heartsprites["fourthpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
  850.              end
  851.           heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn4hearts) if @pkmn4hearts >= 0 && @pkmn4hearts<21
  852.           heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn4hearts.abs) if @pkmn4hearts < 0 && @pkmn4hearts>-21
  853.           @heartsprites["fourthpokehearts"].setBitmap(heartfile)
  854.           sleep(1.0/7.0)
  855.           Graphics.update
  856.         end
  857.         @priorhearts=@pkmn4hearts
  858.     end
  859.   end
  860. ###############################################################################
  861. # Get rid of hearts graphics at end round, and add up heart totals
  862. ###############################################################################
  863. def pbResetHearts
  864.   pbFadeOutAndHide(@heartsprites)
  865.   Graphics.update
  866.   pbDisposeSprite(@heartsprites,"firstpokehearts")
  867.   pbDisposeSprite(@heartsprites,"secondpokehearts")
  868.   pbDisposeSprite(@heartsprites,"thirdpokehearts")
  869.   pbDisposeSprite(@heartsprites,"fourthpokehearts")
  870.   @pkmn1total+=@pkmn1hearts
  871.   @pkmn2total+=@pkmn2hearts
  872.   @pkmn3total+=@pkmn3hearts
  873.   @pkmn4total+=@pkmn4hearts
  874.   @roundonetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==1
  875.   @roundtwototals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==2
  876.   @roundthreetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==3
  877.   @roundfourtotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==4
  878.   @roundfivetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==5
  879.   @pkmn1hearts=0
  880.   @pkmn2hearts=0
  881.   @pkmn3hearts=0
  882.   @pkmn4hearts=0
  883.   Graphics.update
  884.   sleep(1/2)
  885. end
  886.  
  887. def pbDebugTotals(round) #random assortment of numbers, ensuring your pokemon wins.  Intended to be used in debugging the end scene
  888.   @roundonetotals=[20,rand(10),rand(10),rand(10)] if round>0
  889.   @roundtwototals=[20,rand(10),rand(10),rand(10)]
  890.   @roundthreetotals=[20,rand(10),rand(10),rand(10)]
  891.   @roundfourtotals=[20,rand(10),rand(10),rand(10)]
  892.   @roundfivetotals=[20,rand(10),rand(10),rand(10)]
  893.   @pkmn1total=(@roundonetotals[0]+@roundtwototals[0]+@roundthreetotals[0]+@roundfourtotals[0]+@roundfivetotals[0])
  894.   @pkmn2total=(@roundonetotals[1]+@roundtwototals[1]+@roundthreetotals[1]+@roundfourtotals[1]+@roundfivetotals[1])
  895.   @pkmn3total=(@roundonetotals[2]+@roundtwototals[2]+@roundthreetotals[2]+@roundfourtotals[2]+@roundfivetotals[2])
  896.   @pkmn4total=(@roundonetotals[3]+@roundtwototals[3]+@roundthreetotals[3]+@roundfourtotals[3]+@roundfivetotals[3])
  897.  
  898. end
  899. ###############################################################################
  900. #  Determines order for first round, goes by base speed
  901. ###############################################################################
  902.  def pbFindFastestOrderRanking  #Finds the fastest pokemon in the contest
  903.    dexdata=pbOpenDexData
  904.    pbDexDataOffset(dexdata,@pkmn1.species,13)
  905.    basespeed1=dexdata.fgetb
  906.    pokespeed1=basespeed1
  907.    pbDexDataOffset(dexdata,@pkmn2.species,13)
  908.    basespeed2=dexdata.fgetb
  909.    pokespeed2=basespeed2
  910.    pbDexDataOffset(dexdata,@pkmn3.species,13)
  911.    basespeed3=dexdata.fgetb
  912.    pokespeed3=basespeed3
  913.    pbDexDataOffset(dexdata,@pkmn4.species,13)
  914.    basespeed4=dexdata.fgetb
  915.    pokespeed4=basespeed4
  916.    dexdata.close
  917.    fastest = [basespeed1, basespeed2, basespeed3, basespeed4]
  918.    fastest=fastest.sort.reverse
  919.    neworder=[]
  920.    first=(fastest[0]==pokespeed1)? @pkmn1 : ((fastest[0]==pokespeed2) ? @pkmn2 : ((fastest[0]==pokespeed3)? @pkmn3 : @pkmn4))
  921.    neworder.push(first)
  922.    second =(fastest[1]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[1]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[1]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
  923.    neworder.push(second)
  924.    third  =(fastest[2]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[2]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[2]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
  925.    neworder.push(third)
  926.    fourth=(fastest[3]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[3]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[3]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
  927.    neworder.push(fourth)
  928.    @pokeorder=neworder
  929. end
  930.  
  931. ###############################################################################
  932. #     Determine order for next round
  933. ###############################################################################
  934. def pbOrder
  935.    order=[]
  936.    @stars=[]
  937.    mosthearts=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total].sort.reverse
  938.    if @MoveUp.include?(true)
  939.      for i in 0...@MoveUp.length
  940.        if @MoveUp[i]==true && @MoveDown[i]==false
  941.          newpoke=(@pokeorder[i]==@pkmn1)? @pkmn1:(@pokeorder[i]==@pkmn2)? @pkmn2:(@pokeorder[i]==@pkmn3)? @pkmn3:@pkmn4
  942.          order.push(newpoke)
  943.          newstars=(newpoke==@pkmn1)? @pkmn1stars:(newpoke==@pkmn2)? @pkmn2stars:(newpoke==@pkmn3)? @pkmn3stars:@pkmn4stars
  944.          @stars.push(newstars)
  945.         end
  946.      end
  947.    end
  948.    if order.length<4
  949.      for i in 0...@pokeorder.length
  950.        newpoke=nil
  951.          if (mosthearts[i]==@pkmn1total && !(order.include?(@pkmn1)) && @MoveDown[pbCurrentPokeNum2(@pkmn1)]==false)
  952.           newpoke=@pkmn1
  953.          elsif (mosthearts[i]==@pkmn2total && !(order.include?(@pkmn2)) && @MoveDown[pbCurrentPokeNum2(@pkmn2)]==false)
  954.           newpoke=@pkmn2
  955.          elsif (mosthearts[i]==@pkmn3total && !(order.include?(@pkmn3)) && @MoveDown[pbCurrentPokeNum2(@pkmn3)]==false)
  956.           newpoke=@pkmn3
  957.          elsif (mosthearts[i]==@pkmn4total && !(order.include?(@pkmn4)) && @MoveDown[pbCurrentPokeNum2(@pkmn4)]==false)
  958.           newpoke=@pkmn4
  959.          end
  960.           if newpoke !=nil
  961.            order.push(newpoke)
  962.            newstars=(newpoke==@pkmn1)? @pkmn1stars:(newpoke==@pkmn2)? @pkmn2stars:(newpoke==@pkmn3)? @pkmn3stars:@pkmn4stars
  963.            @stars.push(newstars)
  964.           end
  965.       end
  966.    end
  967.     if @MoveDown.include?(true)
  968.      for i in 0...@pokeorder.length
  969.        if @MoveDown[i]==true && @MoveUp[i]==false
  970.          newpoke=(@pokeorder[i]==@pkmn1)? @pkmn1:(@pokeorder[i]==@pkmn2)? @pkmn2:(@pokeorder[i]==@pkmn3)? @pkmn3:@pkmn4
  971.          order.push(newpoke)
  972.          newstars=(newpoke==@pkmn1)? @pkmn1stars:(newpoke==@pkmn2)? @pkmn2stars:(newpoke==@pkmn3)? @pkmn3stars:@pkmn4stars
  973.          @stars.push(newstars)
  974.        end
  975.      end
  976.    end
  977.    if @Scramble==true  #random order for Scramble
  978.      orders=[@pkmn1,@pkmn2,@pkmn3,@pkmn4]
  979.      @stars=[@pmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
  980.      Kernel.srand
  981.      order.shuffle
  982.      Kernel.srand
  983.      @stars.shuffle
  984.    end
  985.   @pokeorder.clear
  986.   @pokeorder=order
  987. end
  988.  
  989. ###############################################################################
  990. #  Display Pokemon Graphics
  991. ###############################################################################
  992. def pbDisplayFastest  #Displays the sprite of the fastest pokemon, as per FindFastest
  993.     @sprites["pokemon1"]=PokemonSprite.new(@viewport)
  994.     @sprites["pokemon1"].setPokemonBitmap(@pokeorder[0],true)
  995.     @sprites["pokemon1"].mirror=true
  996.     pokemony=Graphics.height/2-32
  997.     pokemonyadjust=pokemony-32
  998.     pbPositionPokemonSprite(@sprites["pokemon1"],178,112)
  999. end
  1000. def pbDisplaySecondFastest
  1001.   @sprites["pokemon2"]=PokemonSprite.new(@viewport)
  1002.     @sprites["pokemon2"].setPokemonBitmap(@pokeorder[1],true)
  1003.     @sprites["pokemon2"].mirror=true
  1004.     pokemony=Graphics.height/2-32
  1005.     pokemonyadjust=pokemony-32
  1006.     pbPositionPokemonSprite(@sprites["pokemon2"],178,112)
  1007.   end
  1008.   def pbDisplayThirdFastest
  1009.   @sprites["pokemon3"]=PokemonSprite.new(@viewport)
  1010.     @sprites["pokemon3"].setPokemonBitmap(@pokeorder[2],true)
  1011.     @sprites["pokemon3"].mirror=true
  1012.     pokemony=Graphics.height/2-32
  1013.     pokemonyadjust=pokemony-32
  1014.     pbPositionPokemonSprite(@sprites["pokemon3"],178,112)
  1015.   end
  1016.   def pbDisplayFourthFastest
  1017.   @sprites["pokemon4"]=PokemonSprite.new(@viewport)
  1018.     @sprites["pokemon4"].setPokemonBitmap(@pokeorder[3],true)
  1019.     @sprites["pokemon4"].mirror=true
  1020.     pokemony=Graphics.height/2-32
  1021.     pokemonyadjust=pokemony-32
  1022.     pbPositionPokemonSprite(@sprites["pokemon4"],178,112)
  1023.   end
  1024.  
  1025. #Didn't use this method
  1026. def pbCurrentPokeNum(currentpos)  #find pokemon's number (i.e. 1 for @pkmn1)
  1027.     case @pokeorder[currentpos-1]
  1028.       when @pkmn1
  1029.       return 1
  1030.       when @pkmn2
  1031.       return 2
  1032.       when @pkmn3
  1033.       return 3
  1034.       else pkmn4
  1035.       return 4
  1036.     end
  1037. end
  1038.    
  1039. def pbCurrentPokeNum2(poke)  #find pokemon's number (i.e. 1 for @pkmn1)
  1040.   for i in 0..3
  1041.     if @pokeorder[i]==poke
  1042.      return i
  1043.     end
  1044.   end
  1045. end
  1046.  
  1047.  
  1048.   def pbResetContestMoveEffects  #End round reset
  1049.     @Oblivious=[false,false,false,false]
  1050.     @AvoidOnce=[0,0,0,0]
  1051.     @Scramble=false
  1052.     @MoveUp=[false,false,false,false]
  1053.     @MoveDown=[false,false,false,false]
  1054.     @UpCondition=[false,false,false,false]
  1055.     @previoushearts=0
  1056.     @crowdexcitment=true
  1057.     @goodappeal=[false,false,false,false]
  1058.     @easilystartled=[false,false,false,false]
  1059.     @nervous=[false,false,false,false]
  1060.     @jamaffected=[false,false,false,false]
  1061.     @hasattention=[false,false,false,false]
  1062.     pbNervousGraphic
  1063.     pbObliviousGraphic
  1064.   end
  1065.  
  1066.      
  1067. ###############################################################################
  1068. #   Adjusts hearts via movefunctions.  New move functions go in case statement
  1069. ###############################################################################
  1070.   def pbFunctionsAdjustHearts
  1071.     contestmovedata=PBContestMoveData.new(@currentmove)
  1072.     @currentfunction=contestmovedata.contestfunction
  1073.     @currentjam=contestmovedata.jam
  1074.     i=@currentpos-1
  1075.     case @currentfunction
  1076.     when 1
  1077.       @AvoidOnce[i]=1
  1078.       pbObliviousGraphic
  1079.       when 2
  1080.       @Oblivious[i]=true
  1081.       pbObliviousGraphic
  1082.       when 3
  1083.       @MoveUp[i]=true
  1084.       when 4
  1085.       @UpCondition[i]=true
  1086.     when 5
  1087.       Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the other Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1088.       if @currentpos==4
  1089.         if @Oblivious[2]==true
  1090.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1091.         elsif @AvoidOnce[2]>0
  1092.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1093.          @AvoidOnce[2]=0
  1094.          pbObliviousGraphic
  1095.        else
  1096.          pbStartleGraphic(2)
  1097.          pbJam(@currentjam,@pokeorder[2],3)
  1098.          pbDecreaseHearts(@pokeorder[2],3)
  1099.          pbStartleGraphic(2,2)
  1100.        end
  1101.         if @Oblivious[1]==true
  1102.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1103.         elsif @AvoidOnce[1]>0
  1104.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1105.          @AvoidOnce[1]=0
  1106.          pbObliviousGraphic
  1107.        else
  1108.          pbStartleGraphic(1)
  1109.          pbJam(@currentjam,@pokeorder[1],2)
  1110.          pbDecreaseHearts(@pokeorder[1],2)
  1111.          pbStartleGraphic(1,1)
  1112.        end
  1113.         if @Oblivious[0]==true
  1114.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1115.         elsif @AvoidOnce[0]>0
  1116.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1117.          @AvoidOnce[0]=0
  1118.          pbObliviousGraphic
  1119.        else
  1120.          pbStartleGraphic(0)
  1121.          pbJam(@currentjam,@pokeorder[0],1)
  1122.          pbDecreaseHearts(@pokeorder[0],1)
  1123.          pbStartleGraphic(0,0)
  1124.          end
  1125.        elsif @currentpos==3
  1126.              if @Oblivious[1]==true
  1127.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1128.         elsif @AvoidOnce[1]>0
  1129.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1130.          @AvoidOnce[1]=0
  1131.          pbObliviousGraphic
  1132.        else
  1133.          pbStartleGraphic(1)
  1134.          pbJam(@currentjam,@pokeorder[1],2)
  1135.          pbDecreaseHearts(@pokeorder[1],2)
  1136.          pbStartleGraphic(1,1)
  1137.        end
  1138.             if @Oblivious[0]==true
  1139.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1140.         elsif @AvoidOnce[0]>0
  1141.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1142.          @AvoidOnce[0]=0
  1143.          pbObliviousGraphic
  1144.        else
  1145.          pbStartleGraphic(0)
  1146.          pbJam(@currentjam,@pokeorder[0],1)
  1147.          pbDecreaseHearts(@pokeorder[0],1)
  1148.          pbStartleGraphic(0,0)
  1149.          end
  1150.          elsif @currentpos==2
  1151.               if @Oblivious[0]==true
  1152.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1153.         elsif @AvoidOnce[0]>0
  1154.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1155.          @AvoidOnce[0]=0
  1156.         pbObliviousGraphic
  1157.       else
  1158.         pbStartleGraphic(0)
  1159.          pbJam(@currentjam,@pokeorder[0],1)
  1160.          pbDecreaseHearts(@pokeorder[0],1)
  1161.          pbStartleGraphic(0,0)
  1162.        end
  1163.       else
  1164.      Kernel.pbCustomMessage(_INTL("\\l[3]But it failed.."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)  
  1165.      end
  1166.     when 6
  1167.         @currenthearts=@currentpos
  1168.         @currenthearts=(@currentpos+1) if @currenpos==4
  1169.     when 7  
  1170.       for j in 0...3
  1171.         if @hasattention[j]==true && !(j==@currentpos-1)
  1172.            if @Oblivious[j]==true
  1173.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1174.         elsif @AvoidOnce[j]>0
  1175.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1176.          @AvoidOnce[j]=0
  1177.          pbObliviousGraphic
  1178.        else  
  1179.          pbStartleGraphic(j-1)
  1180.         pbJam(@currentjam,@pokeorder[j],j+1)
  1181.          pbDecreaseHearts(@pokeorder[j],j+1)
  1182.          pbStartleGraphic(j-1,j-1)
  1183.          end
  1184.        end
  1185.      end
  1186.    when 8
  1187.      Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the previous Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1188.       if @currentpos==4
  1189.         if @Oblivious[2]==true
  1190.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1191.         elsif @AvoidOnce[2]>0
  1192.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1193.          @AvoidOnce[2]=0
  1194.          pbObliviousGraphic
  1195.        else  
  1196.          pbStartleGraphic(2)
  1197.          pbJam(@currentjam,@pokeorder[2],3)
  1198.          pbDecreaseHearts(@pokeorder[2],3)
  1199.          pbStartleGraphic(2,2)
  1200.        end
  1201.        elsif @currentpos==3
  1202.              if @Oblivious[1]==true
  1203.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1204.         elsif @AvoidOnce[1]>0
  1205.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1206.          @AvoidOnce[1]=0
  1207.          pbObliviousGraphic
  1208.        else
  1209.          pbStartleGraphic(1)
  1210.          pbJam(@currentjam,@pokeorder[1],2)
  1211.          pbDecreaseHearts(@pokeorder[1],2)
  1212.          pbStartleGraphic(1,1)
  1213.        end
  1214.          elsif @currentpos==2
  1215.               if @Oblivious[0]==true
  1216.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1217.         elsif @AvoidOnce[0]>0
  1218.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1219.          @AvoidOnce[0]=0
  1220.          pbObliviousGraphic
  1221.        else
  1222.          pbStartleGraphic(0)
  1223.          pbJam(@currentjam,@pokeorder[0],1)
  1224.          pbDecreaseHearts(@pokeorder[0],1)
  1225.          pbStartleGraphic(0,0)
  1226.          end
  1227.            else
  1228.            end
  1229.   when 9
  1230.     if @priorhearts[@currentpos-1]>=3
  1231.        @currenthearts=(@currenthearts*2)
  1232.      else
  1233.        @currenthearts==1
  1234.      end
  1235.   when 10
  1236.      @easilystartled[i]=true
  1237.    when 11
  1238.      @MoveDown[i]=true
  1239.    when 12
  1240.      for j in 0..3
  1241.         if @priorhearts[j]>3
  1242.             if @Oblivious[j]==true
  1243.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1244.         elsif @AvoidOnce[j]>0
  1245.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1246.          @AvoidOnce[j]=0
  1247.          pbObliviousGraphic
  1248.        else  
  1249.          pbStartleGraphic(j-1)
  1250.         pbJam(@currentjam,@pokeorder[j],j+1)
  1251.          pbDecreaseHearts(@pokeorder[j],j+1)
  1252.          pbStartleGraphic(j-1,j-1)
  1253.        end
  1254.      end
  1255.      end
  1256.   when 13
  1257.      Kernel.pbCustomMessage(_INTL("\\l[3]The crowd died down!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1258.      @crowdexcitment=false
  1259.   when 14
  1260.     if @currentpos==1
  1261.     Kernel.pbCustomMessage(_INTL("\\l[3]The standout {1} hustled even more!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1262.     @currenthearts=(@currenthearts*2)
  1263.     end
  1264.   when 16  
  1265.     pbSetMissTurn
  1266.     Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the other Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1267.       if @currentpos==4
  1268.         if @Oblivious[2]==true
  1269.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1270.         elsif @AvoidOnce[2]>0
  1271.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1272.          @AvoidOnce[2]=0
  1273.        pbObliviousGraphic
  1274.      else  
  1275.        pbStartleGraphic(2)
  1276.          pbJam(@currentjam,@pokeorder[2],3)
  1277.          pbDecreaseHearts(@pokeorder[2],3)
  1278.          pbStartleGraphic(2,2)
  1279.        end
  1280.         if @Oblivious[1]==true
  1281.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1282.         elsif @AvoidOnce[1]>0
  1283.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1284.          @AvoidOnce[1]=0
  1285.          pbObliviousGraphic
  1286.        else
  1287.          pbStartleGraphic(1)
  1288.          pbJam(@currentjam,@pokeorder[1],2)
  1289.          pbDecreaseHearts(@pokeorder[1],2)
  1290.          pbStartleGraphic(1,1)
  1291.        end
  1292.         if @Oblivious[0]==true
  1293.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1294.         elsif @AvoidOnce[0]>0
  1295.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1296.          @AvoidOnce[0]=0
  1297.          pbObliviousGraphic
  1298.        else
  1299.          pbStartleGraphic(0)
  1300.          pbJam(@currentjam,@pokeorder[0],1)
  1301.          pbDecreaseHearts(@pokeorder[0],1)
  1302.          pbStartleGraphic(0,0)
  1303.          end
  1304.        elsif @currentpos==3
  1305.              if @Oblivious[1]==true
  1306.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1307.         elsif @AvoidOnce[1]>0
  1308.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1309.          @AvoidOnce[1]=0
  1310.          pbObliviousGraphic
  1311.        else
  1312.          pbStartleGraphic(1)
  1313.          pbJam(@currentjam,@pokeorder[1],2)
  1314.          pbDecreaseHearts(@pokeorder[1],2)
  1315.          pbStartleGraphic(1,1)
  1316.        end
  1317.             if @Oblivious[0]==true
  1318.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1319.         elsif @AvoidOnce[0]>0
  1320.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1321.          @AvoidOnce[0]=0
  1322.          pbObliviousGraphic
  1323.        else
  1324.          pbStartleGraphic(0)
  1325.          pbJam(@currentjam,@pokeorder[0],1)
  1326.          pbDecreaseHearts(@pokeorder[0],1)
  1327.          pbStartleGraphic(0,0)
  1328.          end
  1329.          elsif @currentpos==2
  1330.               if @Oblivious[0]==true
  1331.           Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1332.         elsif @AvoidOnce[0]>0
  1333.          Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1334.          @AvoidOnce[0]=0
  1335.          pbObliviousGraphic
  1336.        else
  1337.          pbStartleGraphic(0)
  1338.          pbJam(@currentjam,@pokeorder[0],1)
  1339.          pbDecreaseHearts(@pokeorder[0],1)
  1340.          pbStartleGraphic(0,0)
  1341.          end
  1342.            else
  1343.            end
  1344.   when 17
  1345.     if @currentpos==1
  1346.        for j in 1..3
  1347.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1348.          @nervous[j]=true
  1349.        end
  1350.      elsif @currentpos==2
  1351.         for i in 2..3
  1352.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1353.          @nervous[j]=true
  1354.        end
  1355.      elsif @currentpos==3
  1356.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1357.          @nervous[3]=true
  1358.        end
  1359.        pbNervousGraphic
  1360.   when 18    
  1361.    pbSetNoMoreMoves  
  1362.   when 19    
  1363.        @currenthearts=(@applause+1)
  1364.   when 20    
  1365.      @currenthearts=(rand(5)+1)  
  1366.   when 21
  1367.     if @currentpos==4
  1368.     Kernel.pbCustomMessage(_INTL("\\l[3]The standout {1} hustled even more!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1369.     @currenthearts=5
  1370.     end
  1371.   when 22  
  1372.    if @currentpos==0
  1373.     Kernel.pbCustomMessage(_INTL("\\l[3]But it failed."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1374.   else
  1375.     for j in 0...@currentpos-1
  1376.       pbDecreaseStarGraphics(j,1)
  1377.     end
  1378.     end
  1379.   when 23
  1380.     @currenthearts=@currentpos
  1381.     @currenthearts=(@currentpos+1) if @currenpos==4
  1382.   when 24  
  1383.     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)
  1384.     @Scramble=true
  1385.   when 25  
  1386.     if @moveType==@lastmoveType
  1387.        @currenthearts=(@currenthearts*2)
  1388.     end
  1389.   when 26  
  1390.     @MoveDown[i]=true
  1391.   when 27
  1392.     pbSetDoubleNext
  1393.     Kernel.pbCustomMessage(_INTL("\\l[3]{1} is getting prepared.",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1394.     @currenthearts=1
  1395.   when 28  
  1396.     @currenthearts=(rand(5)+1)
  1397.   when 29  
  1398.     if @currentpos==1
  1399.     @currenthearts=1
  1400.     else
  1401.      if @priorhearts[@currentpos-1]<3
  1402.       @currenthearts=(@currenthearts*2)
  1403.      else
  1404.       @currenthearts=1
  1405.        end
  1406.      end
  1407.    when 30
  1408.      if @currentpos==1
  1409.     @currenthearts=1
  1410.     else
  1411.       @currenthearts=(@priorhearts[currentpos-1]/2).floor
  1412.      end
  1413.   when 31
  1414.    @applause=5
  1415.    pbCrowd(move="notnil")
  1416.   when 32  
  1417.   if @currentpos==0
  1418.     Kernel.pbCustomMessage(_INTL("\\l[3]But if failed."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1419.   elsif
  1420.     for j in 0...@currentpos
  1421.       if @stars[j]>0
  1422.         pbDecreaseStarGraphics(j,1)
  1423.       end
  1424.     end
  1425.     end
  1426.   when 33  
  1427.     @currenthearts=@applause
  1428.   when 34  
  1429.     @currenthearts=@priorhearts[currentpos-1]
  1430.   when 35
  1431.     @currenthearts=@stars[@currentpos-1]    
  1432.   when 36  
  1433.     if @movetype==@contestType
  1434.     @currenthearts=(@currenthearts+1)
  1435.     else
  1436.       @currenthearts=@currenthearts    
  1437.     end
  1438.   when 37
  1439.     @currenthearts=(@currenthearts+@priorhearts[@currentpos-1])
  1440.   when 38  
  1441.     currentApplause = @applause
  1442.     currentApplause = 5 if currentApplause<0 || 5<currentApplause
  1443.     @currenthearts=6-currentApplause
  1444.   when 39  
  1445.     @currenthearts=(@round+1)
  1446.   when 40
  1447.    if @currentpos>1
  1448.     if @priorhearts[@currentpos-1] >3
  1449.     @currenthearts=(@currenthearts*2)
  1450.     end
  1451.   else
  1452.     @currenthearts=1
  1453.   end
  1454.   when 41
  1455.   @currenthearts=@applause
  1456.   else
  1457.     @currenthearts=@currenthearts
  1458.       end
  1459.     end
  1460.  
  1461. ###############################################################################
  1462. #   Controls Applause meter
  1463. ###############################################################################
  1464.   def pbCrowd(move=nil)
  1465.     xPos=-172
  1466.     @sprites["Applause Bar"]=IconSprite.new(xPos,0,@viewport)
  1467.     @sprites["Applause Bar"].setBitmap("Graphics/Pictures/Contest/applause")
  1468.     applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
  1469.     @sprites["applausemeter"]=IconSprite.new((xPos+19),50,@viewport)
  1470.     @sprites["applausemeter"].setBitmap(applausefile)
  1471.     43.times do |i|
  1472.     xPos+=4
  1473.     @sprites["applausemeter"].x=(xPos+19)
  1474.     @sprites["Applause Bar"].x=xPos
  1475.     Graphics.update
  1476.     end
  1477.     if move==nil
  1478.     if @moveType==@contestType
  1479.     @applause=(@applause+1)
  1480.     applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
  1481.     @sprites["applausemeter"].setBitmap(applausefile)
  1482.     Graphics.update
  1483.     if @moveType=="Beauty"
  1484.       Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2} went over great!",@pokeorder[@currentpos-1].name,@contestType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
  1485.     else
  1486.      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)
  1487.     end
  1488.     @currenthearts=1
  1489.     pbDisplayAddingPositiveHearts
  1490.   else
  1491.     if @moveType=="Beauty"
  1492.       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)
  1493.       else
  1494.     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)
  1495.     end
  1496.     if @applause>0
  1497.     @applause-=1
  1498.     applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
  1499.     @sprites["applausemeter"].setBitmap(applausefile)
  1500.     end
  1501.     pbJam(1,@pokeorder[@currentpos-1],@currentpos)
  1502.     pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,"notnil")
  1503.     Graphics.update
  1504.   end
  1505.   if @crowdexcitment==true && @applause==5
  1506.     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)
  1507.     @currenthearts=5
  1508.     pbDisplayAddingPositiveHearts
  1509.     @applause=0
  1510.   end
  1511.   if @sprites["Applause Bar"]
  1512.      43.times do |i|
  1513.     xPos-=4    
  1514.     @sprites["Applause Bar"].x=xPos
  1515.     @sprites["applausemeter"].x=xPos+19 if @sprites["applausemeter"]
  1516.     Graphics.update
  1517.   end
  1518.   end
  1519.   pbDisposeSprite(@sprites,"Applause Bar") if @sprites["Applause Bar"]
  1520.   pbDisposeSprite(@sprites,"applausemeter") if @sprites["applausemeter"]
  1521.   Graphics.update
  1522.   end
  1523. end
  1524.  
  1525.   def pbJam(jam,target,position)
  1526.     case target
  1527.         when @pkmn1
  1528.           @pkmn1jam=jam
  1529.         when @pkmn2
  1530.           @pkmn2jam=jam
  1531.         when @pkmn3
  1532.           @pkmn3jam=jam
  1533.         else
  1534.           @pkmn4jam=jam
  1535.     end
  1536.   end
  1537.  
  1538. ###############################################################################
  1539. # Miscellaneous Graphic functions
  1540. ###############################################################################
  1541. def pbNervousGraphic
  1542.     if @nervous[0]==true && !@sprites["nervousone"]
  1543.         @sprites["nervousone"]=IconSprite.new(374,47,@viewport)
  1544.         @sprites["nervousone"].setBitmap("Graphics/Pictures/Contest/nervous")
  1545.     end
  1546.     if @nervous[1]==true && !@sprites["nervoustwo"]
  1547.       @sprites["nervoustwo"]=IconSprite.new(374,143,@viewport)
  1548.       @sprites["nervoustwo"].setBitmap("Graphics/Pictures/Contest/nervous")
  1549.      end
  1550.      if @nervous[2]==true && !@sprites["nervousthree"]
  1551.       @sprites["nervousthree"]=IconSprite.new(374,239,@viewport)
  1552.       @sprites["nervousthree"].setBitmap("Graphics/Pictures/Contest/nervous")
  1553.     end  
  1554.     if @nervous[3]==true && !@sprites["nervousfour"]
  1555.       @sprites["nervousfour"]=IconSprite.new(374,335,@viewport)
  1556.       @sprites["nervousfour"].setBitmap("Graphics/Pictures/Contest/nervous")
  1557.     end  
  1558.     if @nervous[0]==false
  1559.         pbDisposeSprite(@sprites,"nervousone") if @sprites["nervousone"]
  1560.     end
  1561.     if @nervous[1]==false
  1562.         pbDisposeSprite(@sprites,"nervoustwo") if @sprites["nervoustwo"]
  1563.     end
  1564.     if @nervous[2]==false  
  1565.         pbDisposeSprite(@sprites,"nervousthree") if @sprites["nervousthree"]
  1566.     end
  1567.     if @nervous[3]==false  
  1568.        pbDisposeSprite(@sprites,"nervousfour") if @sprites["nervousfour"]
  1569.     end
  1570.   end
  1571.  
  1572. def pbObliviousGraphic
  1573.     if (@Oblivious[0]==true || @AvoidOnce[0]>0) && !@sprites["obliviousone"]
  1574.         @sprites["obliviousone"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
  1575.         @sprites["obliviousone"].setBitmap("Graphics/Pictures/Contest/oblivious")
  1576.     end
  1577.     if (@Oblivious[1]==true || @AvoidOnce[1]>0) && !@sprites["oblivioustwo"]
  1578.       @sprites["oblivioustwo"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
  1579.       @sprites["oblivioustwo"].setBitmap("Graphics/Pictures/Contest/oblivious")
  1580.      end
  1581.      if (@Oblivious[2]==true || @AvoidOnce[2]>0) && !@sprites["obliviousthree"]
  1582.       @sprites["obliviousthree"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
  1583.       @sprites["obliviousthree"].setBitmap("Graphics/Pictures/Contest/oblivious")
  1584.     end  
  1585.     if (@Oblivious[3]==true || @AvoidOnce[3]>0) && !@sprites["obliviousfour"]
  1586.       @sprites["obliviousfour"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
  1587.       @sprites["obliviousfour"].setBitmap("Graphics/Pictures/Contest/oblivious")
  1588.     end  
  1589.     if @Oblivious[0]==false && @AvoidOnce[0]==0
  1590.         pbDisposeSprite(@sprites,"obliviousone") if @sprites["obliviousone"]
  1591.     end
  1592.     if @Oblivious[1]==false && @AvoidOnce[1]==0
  1593.         pbDisposeSprite(@sprites,"oblivioustwo") if @sprites["oblivioustwo"]
  1594.     end
  1595.     if @Oblivious[2]==false && @AvoidOnce[2]==0
  1596.         pbDisposeSprite(@sprites,"obliviousthree") if @sprites["obliviousthree"]
  1597.     end
  1598.     if @Oblivious[3]==false && @AvoidOnce[3]==0
  1599.        pbDisposeSprite(@sprites,"obliviousfour") if @sprites["obliviousfour"]
  1600.     end
  1601. end
  1602.  
  1603.  def pbStartleGraphic(position,deletepos=5)
  1604.      if position==0 && !@sprites["startleone"]
  1605.         @sprites["startleone"]=IconSprite.new(374,47,@viewport)
  1606.         @sprites["startleone"].setBitmap("Graphics/Pictures/Contest/startle")
  1607.     end
  1608.     if position==1 && !@sprites["startletwo"]
  1609.       @sprites["startletwo"]=IconSprite.new(374,143,@viewport)
  1610.       @sprites["startletwo"].setBitmap("Graphics/Pictures/Contest/startle")
  1611.      end
  1612.      if position==2 && !@sprites["startlethree"]
  1613.       @sprites["startlethree"]=IconSprite.new(374,239,@viewport)
  1614.       @sprites["startlethree"].setBitmap("Graphics/Pictures/Contest/startle")
  1615.     end  
  1616.     if position==3 && !@sprites["startlefour"]
  1617.       @sprites["startlefour"]=IconSprite.new(374,335,@viewport)
  1618.       @sprites["startlefour"].setBitmap("Graphics/Pictures/Contest/startle")
  1619.     end
  1620.     if deletepos<5
  1621.     if deletepos==0
  1622.         pbDisposeSprite(@sprites,"startleone") if @sprites["startleone"]
  1623.     end
  1624.     if deletepos==1
  1625.         pbDisposeSprite(@sprites,"startletwo") if @sprites["startletwo"]
  1626.     end
  1627.     if deletepos==2  
  1628.         pbDisposeSprite(@sprites,"startlethree") if @sprites["startlethree"]
  1629.     end
  1630.     if deletepos==3  
  1631.        pbDisposeSprite(@sprites,"startlefour") if @sprites["startlefour"]
  1632.      end
  1633.     end
  1634.   Graphics.update
  1635. end
  1636.  
  1637. def pbDecreaseStarGraphics(position,change,decrease=true)
  1638.   case @stars[position]
  1639.     when @pkmn1stars
  1640.         for i in 0..change
  1641.           @pkmn1stars -= 1 if decrease==true  && @pkmn1stars>0
  1642.           @pkmn1stars += 1 if decrease==false
  1643.           @sprites["firstpokestars"]=IconSprite.new(350,78+(94*position),@viewport) unless @sprites["firstpokestars"]
  1644.           starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn1stars) if @pkmn1stars<=6
  1645.           @sprites["firstpokestars"].setBitmap(starfile)
  1646.           sleep(1.0/7.0)
  1647.           Graphics.update
  1648.           break if @pkmn1stars==0
  1649.         end
  1650.      when @pkmn2stars
  1651.         for i in 0..change
  1652.           @pkmn2stars -= 1 if decrease==true && @pkmn2stars>0
  1653.           @pkmn2stars += 1 if decrease==false
  1654.           @sprites["secondpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["secondpokestars"]
  1655.           starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn2stars) if @pkmn2stars<=6
  1656.           @sprites["secondpokestars"].setBitmap(starfile)
  1657.           sleep(1.0/7.0)
  1658.           Graphics.update
  1659.           break if @pkmn2stars==0
  1660.         end
  1661.      when @pkmn3stars
  1662.         for i in 0..change
  1663.           @pkmn3stars -= 1 if decrease==true && @pkmn3stars>0
  1664.           @pkmn3stars += 1 if decrease==false
  1665.           @sprites["thirdpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["thirdpokestars"]
  1666.           starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn3stars) if @pkmn3stars<=6
  1667.           @sprites["thirdpokestars"].setBitmap(starfile)
  1668.           sleep(1.0/7.0)
  1669.           Graphics.update
  1670.           break if @pkmn3stars==0
  1671.         end
  1672.        when @pkmn4stars
  1673.         for i in 0..change
  1674.           @pkmn4stars -= 1 if decrease==true && @pkmn4stars>0
  1675.           @pkmn4stars += 1 if decrease==false
  1676.           @sprites["fourthpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["fourthpokestars"]
  1677.           starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn4stars) if @pkmn4stars<=6
  1678.           @sprites["fourthpokestars"].setBitmap(starfile)
  1679.           sleep(1.0/7.0)
  1680.           Graphics.update
  1681.           break if @pkmn4stars==0
  1682.         end
  1683.     end
  1684.   end
  1685.  
  1686. ################################################################################
  1687. # Move Buttons
  1688. ################################################################################
  1689.  def pbMoveButtons
  1690.     pokemon=@pkmn1
  1691.     pokename=pokemon.name
  1692.   @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  1693.   @viewport.z=99999
  1694.   @sprites["moves"]=IconSprite.new(0,187,@viewport)
  1695.   @sprites["moves"].setBitmap("Graphics/Pictures/Contest/moves")
  1696.  
  1697.   base=Color.new(64,64,64)
  1698.     shadow=Color.new(0,0,0)
  1699.     @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
  1700.     @sprites["overlay1"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
  1701.     overlay=@sprites["overlay"].bitmap
  1702.     overlay1=@sprites["overlay1"].bitmap
  1703.     pbSetSmallFont(overlay)
  1704.   textpos=[
  1705.        [_INTL("Please select a move."),12,165,0,Color.new(256,256,256),shadow]]
  1706.   imagepos=[]
  1707.   textpos1=[]
  1708.     yPos=195
  1709.     xPos=10
  1710.   selectYPos=191
  1711.   @sprites["selectbar"]=IconSprite.new(6,selectYPos,@viewport)
  1712.   @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1")
  1713.   selection=0
  1714.   selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
  1715.     for i in 1..PBContestMoves.maxValue
  1716.     name=PBContestMoves.getName(i)
  1717.     if selectedmove==name
  1718.       selectedmove=getID(PBContestMoves,i)
  1719.     end
  1720.   end
  1721.   selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
  1722.   contestmovedata=PBContestMoveData.new(selectedmove)
  1723.   selectedhearts=contestmovedata.hearts
  1724.   selectedjam=contestmovedata.jam
  1725.   jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
  1726.   @sprites["selectjam"]=IconSprite.new(400,235,@viewport)
  1727.   @sprites["selectjam"].setBitmap(jamfile)
  1728.   heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
  1729.   @sprites["selecthearts"]=IconSprite.new(400,200,@viewport)
  1730.   @sprites["selecthearts"].setBitmap(heartfile)
  1731.   if @pkmn1.moves[selection].id>0
  1732.     textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
  1733.              Color.new(256,256,256),Color.new(0,0,0)])
  1734.     pbDrawTextPositions(overlay1,textpos1)
  1735.   end  
  1736.   drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
  1737.     for i in 0...pokemon.numMoves
  1738.       if pokemon.moves[i].id>0
  1739.         selectedmove=PBMoves.getName(@pkmn1.moves[i].id)
  1740.        for j in 1..PBContestMoves.maxValue
  1741.       name=PBContestMoves.getName(j)
  1742.       if selectedmove==name
  1743.       selectedmove=getID(PBContestMoves,j)
  1744.        end
  1745.      end
  1746.        
  1747.       contestmovedata=PBContestMoveData.new(selectedmove)
  1748.         moveType=contestmovedata.contestType
  1749.         imagepos.push(["Graphics/Pictures/Contest/contesttype",xPos,yPos,0,
  1750.            moveType*28,64,28])
  1751.         if @pkmn1lastmove && PBMoves.getName(pokemon.moves[i].id)==@pkmn1lastmove
  1752.           textpos.push([PBMoves.getName(pokemon.moves[i].id),xPos+68,yPos+10,0,Color.new(175,175,175),Color.new(0,0,0)])
  1753.         else
  1754.           textpos.push([PBMoves.getName(pokemon.moves[i].id),xPos+68,yPos+10,0,Color.new(256,256,256),Color.new(0,0,0)])
  1755.         end
  1756.       else
  1757.         textpos.push(["-",316,yPos,0,Color.new(256,256,256),Color.new(0,0,0)])
  1758.       end
  1759.       yPos+=44
  1760.     end
  1761.   pbDrawTextPositions(overlay,textpos)
  1762.   pbDrawImagePositions(overlay,imagepos)
  1763.   loop do
  1764.     Graphics.update
  1765.     Input.update
  1766.     self.update
  1767.     if Input.trigger?(Input::DOWN)
  1768.     if selection<pokemon.numMoves-1
  1769.       selection+=1
  1770.     else
  1771.       selection=0
  1772.     end
  1773.     selectYPos=(selection*45 + 192)
  1774.     selectYPos=(selection*45+191) if selection==0
  1775.     selectYPos=(selection*45+190) if selection==1
  1776.     @sprites["selectbar"].y=selectYPos
  1777.     @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1") if selection==0
  1778.     @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect") if selection!=0
  1779.     selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
  1780.     for i in 1..PBContestMoves.maxValue
  1781.       name=PBContestMoves.getName(i)
  1782.       if selectedmove==name
  1783.         selectedmove=getID(PBContestMoves,i)
  1784.       end
  1785.     end
  1786.   contestmovedata=PBContestMoveData.new(selectedmove)
  1787.   selectedhearts=contestmovedata.hearts
  1788.   selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
  1789.   heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
  1790.   selectedjam=contestmovedata.jam
  1791.   jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
  1792.   @sprites["selectjam"].setBitmap(jamfile)
  1793.   @sprites["selecthearts"].setBitmap(heartfile)
  1794.   overlay1.clear
  1795.   textpos1.clear
  1796.   @sprites["overlay1"].bitmap
  1797.     textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
  1798.            Color.new(256,256,256),Color.new(0,0,0)])
  1799.     drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
  1800.     pbDrawTextPositions(overlay1,textpos1)
  1801.     end
  1802.     if Input.trigger?(Input::UP)
  1803.     if selection>0
  1804.       selection-=1
  1805.     else
  1806.       selection=pokemon.numMoves-1
  1807.     end
  1808.     selectYPos=(selection*45 + 192)
  1809.     selectYPos=(selection*45+191) if selection==0
  1810.     selectYPos=(selection*45+190) if selection==1
  1811.     @sprites["selectbar"].y=selectYPos
  1812.     @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1") if selection==0
  1813.     @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect") if selection!=0
  1814.     selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
  1815.     for i in 1..PBContestMoves.maxValue
  1816.     name=PBContestMoves.getName(i)
  1817.     if selectedmove==name
  1818.       selectedmove=getID(PBContestMoves,i)
  1819.     end
  1820.    end
  1821.   contestmovedata=PBContestMoveData.new(selectedmove)
  1822.   selectedhearts=contestmovedata.hearts
  1823.   selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
  1824.   selectedjam=contestmovedata.jam
  1825.   jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
  1826.   @sprites["selectjam"].setBitmap(jamfile)
  1827.   heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
  1828.   @sprites["selecthearts"].setBitmap(heartfile)
  1829.     overlay1.clear
  1830.   textpos1.clear
  1831.   @sprites["overlay1"].bitmap
  1832.     textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
  1833.            Color.new(256,256,256),Color.new(0,0,0)])
  1834.     drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
  1835.     pbDrawTextPositions(overlay1,textpos1)
  1836.     end
  1837.     if Input.trigger?(Input::C)
  1838.       @moveselection=selection
  1839.       overlay.clear
  1840.       overlay1.clear
  1841.       textpos.clear
  1842.       imagepos.clear
  1843.       textpos1.clear
  1844.       pbDisposeSprite(@sprites,"selecthearts")
  1845.       pbDisposeSprite(@sprites,"moves")
  1846.       pbDisposeSprite(@sprites,"selectbar")
  1847.       pbDisposeSprite(@sprites,"selectjam")
  1848.       pbDisposeSprite(@sprites,"overlay")
  1849.       pbDisposeSprite(@sprites,"overlay1")
  1850.       Graphics.update
  1851.       break
  1852.     end
  1853.     end
  1854.   end
  1855.  
  1856.   def pbEndScene  #Ends everything
  1857.     for i in 0..3
  1858.      CONTESTMOVE2[i]=0 #reset these global variables for next use
  1859.      CONTESTMOVE3[i]=0
  1860.      CONTESTMOVE4[i]=0
  1861.     end
  1862.     $CONTESTNAME2="" #reset these global variables for next use
  1863.     $CONTESTNAME3=""
  1864.     $CONTESTNAME4=""
  1865.     $game_map.autoplay
  1866.     pbFadeOutAndHide(@sprites) { update }
  1867.     pbDisposeSpriteHash(@heartsprites) if @heartsprites
  1868.     pbDisposeSpriteHash(@sprites)
  1869.     @viewport.dispose
  1870.     $scene = Scene_Map.new
  1871.   end
  1872.  
  1873.   def middleScene  #processes scene after startScene
  1874.      loop do
  1875.     Graphics.update
  1876.     Input.update
  1877.     self.update
  1878.     if @contestover
  1879.        break
  1880.      end
  1881.      end
  1882.    end
  1883. ###############################################################################  
  1884. ####################  Animation Stuff Below ###################################
  1885. ############## Don't change unless you know what you're doing #################
  1886. ###############################################################################  
  1887.    def pbFindAnimation(moveid,userIndex,hitnum)
  1888.     begin
  1889.       move2anim=load_data("Data/move2anim.dat")
  1890.       noflip=false
  1891.       if (userIndex&1)==0   # On player's side
  1892.         anim=move2anim[0][moveid]
  1893.       else                  # On opposing side
  1894.         anim=move2anim[1][moveid]
  1895.         noflip=true if anim
  1896.         anim=move2anim[0][moveid] if !anim
  1897.       end
  1898.       return [anim+hitnum,noflip] if anim
  1899.       if hasConst?(PBMoves,:TACKLE)
  1900.         anim=move2anim[0][getConst(PBMoves,:TACKLE)]
  1901.         return [anim,false] if anim
  1902.       end
  1903.     rescue
  1904.       return nil
  1905.     end
  1906.     return nil
  1907.   end
  1908.  
  1909.   def pbAnimation(moveid,user,target,hitnum=0)
  1910.     animid=pbFindAnimation(moveid,0,hitnum)
  1911.     return if !animid
  1912.     anim=animid[0]
  1913.     animations=load_data("Data/PkmnAnimations.rxdata")
  1914.     pbSaveShadows {
  1915.        if animid[1] # On opposing side and using OppMove animation
  1916.          pbAnimationCore(animations[anim],target,user)
  1917.        else         # On player's side, and/or using Move animation
  1918.          pbAnimationCore(animations[anim],user,target)
  1919.        end
  1920.     }
  1921.   end
  1922.  
  1923.   def pbSaveShadows
  1924.     shadows=[]
  1925.     for i in 0...4
  1926.       s=@sprites["shadow#{i}"]
  1927.       shadows[i]=s ? s.visible : false
  1928.       s.visible=false if s
  1929.     end
  1930.     yield
  1931.     for i in 0...4
  1932.       s=@sprites["shadow#{i}"]
  1933.       s.visible=shadows[i] if s
  1934.     end
  1935.   end
  1936.  
  1937.   def pbAnimationCore(animation,user,target)
  1938.     return if !animation
  1939.     @briefmessage=false
  1940.     case @currentpos
  1941.     when 1
  1942.     usersprite=@sprites["pokemon1"]
  1943.     when 2
  1944.     usersprite=@sprites["pokemon2"]
  1945.     when 3
  1946.     usersprite=@sprites["pokemon3"]
  1947.     when 4
  1948.     usersprite=@sprites["pokemon4"]
  1949.     end
  1950.     targetsprite=(@atself==false)? @sprites["opponent"]:usersprite
  1951.     olduserx=usersprite ? usersprite.x : 0
  1952.     oldusery=usersprite ? usersprite.y : 0
  1953.     oldtargetx=targetsprite ? targetsprite.x : 0
  1954.     oldtargety=targetsprite ? targetsprite.y : 0
  1955.     #Start animation player
  1956.       animplayer=PBAnimationPlayerContest.new(animation,user,target,usersprite,targetsprite,self)
  1957.       userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
  1958.       userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
  1959.       targetwidth=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.width
  1960.       targetheight=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.height
  1961.       animplayer.setLineTransform(
  1962.          PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
  1963.          PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
  1964.          olduserx+(userwidth/2),oldusery+(userheight/2),
  1965.          oldtargetx+(targetwidth/2),oldtargety+(targetheight/2))
  1966.     animplayer.start
  1967.     while animplayer.playing?
  1968.       animplayer.update
  1969.       Graphics.update
  1970.     end
  1971.     usersprite.ox=0 if usersprite
  1972.     usersprite.oy=0 if usersprite
  1973.     usersprite.x=olduserx if usersprite
  1974.     usersprite.y=oldusery if usersprite
  1975.     targetsprite.ox=0 if targetsprite
  1976.     targetsprite.oy=0 if targetsprite
  1977.     targetsprite.x=oldtargetx if targetsprite
  1978.     targetsprite.y=oldtargety if targetsprite
  1979.     animplayer.dispose
  1980.   end
  1981.  
  1982. #                            End of Animation Stuff
  1983. ###############################################################################
  1984.  
  1985.  
  1986.  
  1987. ###############################################################################
  1988. #                                 AI
  1989. ###############################################################################
  1990. def pbAI(pokemon,difficulty)
  1991.   movescores=[]
  1992.   nummoves=pokemon.numMoves-1
  1993.   for i in 0...nummoves
  1994.    score=100
  1995.        move=PBMoves.getName(pokemon.moves[i].id)
  1996.        currentmovename=PBMoves.getName(pokemon.moves[i].id)
  1997.        if pokemon.moves[i].id>0
  1998.        for j in 1..PBContestMoves.maxValue
  1999.        name=PBContestMoves.getName(j)
  2000.         if move==name
  2001.          move=getID(PBContestMoves,j)
  2002.         end
  2003.        end
  2004.    contestmovedata=PBContestMoveData.new(move)
  2005.    hearts=contestmovedata.hearts
  2006.    jam=contestmovedata.jam
  2007.    function=contestmovedata.contestfunction
  2008.    type=contestmovedata.contestType
  2009.    case function
  2010.    when 0                             #No function
  2011.     score+=60 if hearts>3
  2012.     score+=30 if hearts<=3
  2013.    when 1,2  #gains oblivious.  Increase score for earlier position
  2014.        case @currentpos
  2015.        when 1
  2016.          score+=60
  2017.        when 2
  2018.          score+=40
  2019.        when 4
  2020.          score-=20
  2021.        end
  2022.    when 3   #Move Up in order
  2023.        if @currentpos==4
  2024.         score+=30
  2025.        else
  2026.         score+=10
  2027.        end
  2028.    when 4  #Ups condition
  2029.       score+=30
  2030.    when 5   #Tries to startle previous pokemons
  2031.       case @currentpos
  2032.        when 4
  2033.          score+=70
  2034.        when 3
  2035.          score+=40
  2036.        when 1
  2037.          score-=20
  2038.        end
  2039.    when 6,23   #works better later
  2040.       case @currentpos
  2041.        when 4
  2042.          score+=70
  2043.        when 3
  2044.          score+=40
  2045.        when 1
  2046.          score-=20
  2047.        end
  2048.    when 7   #deducts from pokemon that has judges attention
  2049.        for k in 0...@currentpos
  2050.        score+=30 if @hasattention[k]==true
  2051.        end
  2052.    when 8  #startles pokemon in front
  2053.        case @currentpos
  2054.        when 4
  2055.          score+=40
  2056.        when 3
  2057.          score+=20
  2058.        when 1
  2059.          score-=20
  2060.        end
  2061.    when 9,40   #better if previous move was better
  2062.        if @priorhearts>=3
  2063.           score+=60
  2064.         else
  2065.           score-=20
  2066.         end
  2067.    when 10   #easily startled
  2068.        case @currentpos
  2069.        when 4
  2070.          score+=60
  2071.        when 3
  2072.          score+=40
  2073.        when 1
  2074.          score-=20
  2075.        end
  2076.     when 11  #move down in order
  2077.         if @currentpos==4
  2078.           score-=20
  2079.         else
  2080.           score+=20
  2081.         end
  2082.     when 12 #startles pokemon with good appeals
  2083.        case @currentpos
  2084.        when 4
  2085.          score+=20
  2086.          score+=30 if @priorhearts>3
  2087.        when 3
  2088.          score+=10
  2089.          score+=30 if @priorhearts>3
  2090.        when 1
  2091.          score-=20
  2092.        end
  2093.     when 13  #stops crowd excitement
  2094.        score -=20 if @applause>3
  2095.        score +=20 if @applause<=3
  2096.     when 14  #works best if performed first
  2097.       if @currentpos==1
  2098.         score+=60
  2099.       end
  2100.     when 15 #can be used multiple times without boring judge
  2101.       score+=20
  2102.     when 16  #jams pokemon and misses turn
  2103.       case @currentpos
  2104.        when 4
  2105.          score+=30
  2106.        when 3
  2107.          score+=20
  2108.        end
  2109.        if @round==5
  2110.          score+=60
  2111.        elsif @round==1
  2112.          score-=10
  2113.        end
  2114.     when 17  #makes all pokemon after nervous
  2115.        case @currentpos
  2116.        when 1
  2117.          score+=60
  2118.        when 2
  2119.          score+=40
  2120.        when 4
  2121.          score-=20
  2122.        end
  2123.     when 18  #no more moves
  2124.       if @round==5
  2125.         score+=90
  2126.       else
  2127.         score-=60
  2128.       end
  2129.     when 19  #depends on applause level
  2130.       score+=20 if @applause>2
  2131.     when 20  #depends on random
  2132.       score+=20
  2133.     when 21   #best if performed last
  2134.        if @currentpos==4
  2135.         score+=60
  2136.        end
  2137.      when 22,32  #removes a star
  2138.         if @currentpos==4 && @stars.max>1 && @stars.index(@stars.max)!=@currentpos-1
  2139.         score+=40
  2140.         end
  2141.      when 24  #Scramble
  2142.        if @round !=5
  2143.          score+=30
  2144.        end
  2145.      when 25 #works better if last move type is the same
  2146.         if @lastmoveType && type==@lastmoveType
  2147.           score+=40
  2148.         else
  2149.           score-=10
  2150.          end
  2151.      when 26  #appeal later next turn
  2152.         if @currentpos==4
  2153.           score-=20
  2154.         else
  2155.           score+=20
  2156.         end
  2157.      when 27  #double next turn
  2158.        if @round !=5
  2159.         score+=40
  2160.        else
  2161.         score-=60
  2162.        end
  2163.      when 28  #random amounts
  2164.        score+=20
  2165.      when 29  #better if last pokemon's wasn't
  2166.        if @priorhearts<3
  2167.           score+=60
  2168.         else
  2169.           score-=20
  2170.         end
  2171.      when 30  #half as much as previous pokemon
  2172.        score+=(@priorhearts/2.floor)*10 if @priorhearts
  2173.      when 31  #gets crowd going
  2174.        score+=40
  2175.      when 33,41  #better based on crowd excitement
  2176.        score+=(@applause*10).floor
  2177.      when 34,37  #same amount as last appearl
  2178.        score+=(@priorhearts.floor)*10 if @priorhearts
  2179.      when 35  #equals the pokemon's stars
  2180.       if @stars[@currentpos-1]>0
  2181.        score+=@stars[@currentpos-1]*10
  2182.        else
  2183.        score-=30
  2184.        end
  2185.      when 36
  2186.        if type==@contestType
  2187.         score+=40
  2188.        else
  2189.         score-=10
  2190.        end
  2191.      when 38  #better for lower applause
  2192.        case @applause
  2193.        when 1
  2194.         score+=60
  2195.        when 2
  2196.         score+=40
  2197.        when 3
  2198.         score+=20
  2199.        when 4
  2200.         score-=20
  2201.        end  
  2202.      when 39  #better for later rounds
  2203.         case @round
  2204.        when 5
  2205.         score+=60
  2206.        when 3
  2207.         score+=40
  2208.        when 2
  2209.         score+=20
  2210.        when 1
  2211.         score-=20
  2212.        end  
  2213.      end
  2214.      score+=60 if type==@contestType  #better if it's the same type as the contest
  2215.      @currentmovename=currentmovename
  2216.      score+=60 if @round>1 && pbCheckforCombos==true  #better if it will result in a combo
  2217.      score-=60 if @round>1 && function !=15 && pbCheckLast
  2218.   end
  2219.     movescores.push(score) if pokemon.moves[i].id>0
  2220.   end
  2221.   #movescores have been added up.  Now find highest value, with a bit of variation
  2222.   stdev=pbStdDev(movescores)
  2223.   choice=movescores.index(movescores.max) #finds highest scoring move
  2224.   notchoice=movescores.index(movescores.min)
  2225.   return choice if stdev>=100 && rand(10)!=0  #use the highest scoring move if it's clearly better (stdev of 100 or more)
  2226.   newmovescores=movescores.clone
  2227.   newmovescores.sort
  2228.   secondlowest=movescores.index(newmovescores[1])
  2229.   r=rand(movescores.length)
  2230.     movescores[notchoice]=nil if difficulty>25
  2231.     movescores[secondlowest]=nil if difficulty>75
  2232.     if difficulty>25  #lowest difficulty
  2233.     return r if movescores[r]!=nil && rand(10)>4
  2234.     elsif difficulty>50
  2235.     return r if movescores[r]!=nil && rand(10)>2
  2236.     elsif difficulty>75
  2237.     2.times do
  2238.     return r if movescores[r]!=nil && rand(10)>2
  2239.     end
  2240.     else
  2241.     return r
  2242.     end
  2243.   return r
  2244. end
  2245.  
  2246. def pbStdDev(scores) #from PokeBattle_AI
  2247.     n=0
  2248.     sum=0
  2249.     scores.each{|s| sum+=s; n+=1 }
  2250.     return 0 if n==0
  2251.     mean=sum.to_f/n.to_f
  2252.     varianceTimesN=0
  2253.     for i in 0...scores.length
  2254.       if scores[i]>0
  2255.         deviation=scores[i].to_f-mean
  2256.         varianceTimesN+=deviation*deviation
  2257.       end
  2258.     end
  2259.     # Using population standard deviation
  2260.     # [(n-1) makes it a sample std dev, would be 0 with only 1 sample]
  2261.     return Math.sqrt(varianceTimesN/n)
  2262.   end
  2263. #                           End of AI
  2264. ###############################################################################
  2265. ###############################################################################
  2266. #                   Preliminary Results.  No graphics used
  2267. ###############################################################################
  2268. def pbPreliminaryScene
  2269.   @prelim1=0
  2270.   @prelim2=0
  2271.   @prelim3=0
  2272.   @prelim4=0
  2273.   #points for players pokemon below
  2274.   case @contestType
  2275.   when "Cool"
  2276.     @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:REDSCARF)
  2277.     @prelim1+=($Trainer.party[$game_variables[36]].cool/8).floor
  2278.   when "Beauty"
  2279.     @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:BLUESCARF)
  2280.     @prelim1+=($Trainer.party[$game_variables[36]].beauty/8).floor
  2281.   when "Smart"
  2282.     @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:GREENSCARF)
  2283.     @prelim1+=($Trainer.party[$game_variables[36]].smart/8).floor
  2284.   when "Tough"
  2285.     @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:YELLOWSCARF)
  2286.     @prelim1+=($Trainer.party[$game_variables[36]].tough/8).floor
  2287.   when "Cute"
  2288.     @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:PINKSCARF)  
  2289.     @prelim1+=($Trainer.party[$game_variables[36]].cute/8).floor
  2290.   end
  2291.   @prelim1+=25 if $Trainer.party[$game_variables[36]].isShiny? #extra points if it's shiny
  2292.   #points for other pokemon below
  2293.   #points for coolness, beauty, etc.  Pokemon are created with 0, so they won't have any, given by difficulty
  2294.   @prelim2+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
  2295.   @prelim3+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
  2296.   @prelim4+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
  2297.   #gives points for "scarves".  Pokemon won't actually have any.  Less likely to
  2298.   @prelim2+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
  2299.   @prelim3+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
  2300.   @prelim4+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
  2301.   #points for shiny
  2302.   @prelim2+=25 if @pkmn2.isShiny?
  2303.   @prelim3+=25 if @pkmn3.isShiny?
  2304.   @prelim4+=25 if @pkmn4.isShiny?
  2305.   #add some randomness for opponents
  2306.   @prelim2+=rand(10)
  2307.   @prelim2-=rand(10)
  2308.   @prelim3+=rand(10)
  2309.   @prelim3-=rand(10)
  2310.   @prelim4+=rand(10)
  2311.   @prelim4-=rand(10)
  2312. end
  2313. ###############################################################################
  2314. #                          Results Scene
  2315. ###############################################################################
  2316.   def pbResultsScene
  2317.     @sprites["results"]=IconSprite.new(0,0,@viewport2)
  2318.     @sprites["results"].setBitmap("Graphics/Pictures/Contest/resultsbg")
  2319.     #draw poke icons
  2320.     @pkmn1sprite=PokemonIconSprite.new(@pkmn1,@viewport2)
  2321.     @pkmn2sprite=PokemonIconSprite.new(@pkmn2,@viewport2)
  2322.     @pkmn3sprite=PokemonIconSprite.new(@pkmn3,@viewport2)
  2323.     @pkmn4sprite=PokemonIconSprite.new(@pkmn4,@viewport2)
  2324.     #positions poke icons
  2325.     @pkmn1sprite.x=86
  2326.     @pkmn2sprite.x=86
  2327.     @pkmn3sprite.x=86
  2328.     @pkmn4sprite.x=86
  2329.     @pkmn1sprite.y=93
  2330.     @pkmn2sprite.y=@pkmn1sprite.y+50
  2331.     @pkmn3sprite.y=@pkmn2sprite.y+50
  2332.     @pkmn4sprite.y=@pkmn3sprite.y+50
  2333.     @sprites["textbitmap"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2) #bitmap to draw text on, instead of Kernel.pbMessage
  2334.     @sprites["textbitmap"].z=@viewport2.z
  2335.     #Color for rectangles, determined by contest type
  2336.     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)
  2337.     #array of the scores to use
  2338.     @results=[@prelim1*1.5.floor,@prelim2*1.5.floor,@prelim3*1.5.floor,@prelim4*1.5.floor]
  2339.     @newstars=[@pkmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
  2340.     #Draw rectangles, using the prelims as the initial
  2341.     textpos=[]
  2342.     textpos.push([_INTL("Preliminary Results"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2343.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2344.     @sprites["overlay2"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2)
  2345.     @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
  2346.     @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
  2347.     @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
  2348.     @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
  2349.     Graphics.update
  2350.     sleep(1)
  2351.     #Draw first round
  2352.     #this could probably be reduced to one loop, but it'll do more calculations in the long run
  2353.     textpos.clear
  2354.     @sprites["textbitmap"].bitmap.clear
  2355.     textpos.push([_INTL("First Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2356.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2357.     3.times do
  2358.       for i in 0..3
  2359.         @results[i]+=@roundonetotals[i]*1.5/3
  2360.       end
  2361.      @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
  2362.      @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
  2363.      @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
  2364.      @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
  2365.      Graphics.update
  2366.      sleep(1)
  2367.     end
  2368.     #Draw second round
  2369.     textpos.clear
  2370.     @sprites["textbitmap"].bitmap.clear
  2371.     textpos.push([_INTL("Second Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2372.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2373.     3.times do
  2374.       for i in 0..3
  2375.         @results[i]+=@roundtwototals[i]*1.5/3
  2376.       end
  2377.      @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
  2378.      @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
  2379.      @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
  2380.      @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
  2381.      Graphics.update
  2382.      sleep(1)
  2383.     end
  2384.     #Draw third round
  2385.     textpos.clear
  2386.     @sprites["textbitmap"].bitmap.clear
  2387.     textpos.push([_INTL("Third Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2388.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2389.     3.times do
  2390.       for i in 0..3
  2391.         @results[i]+=@roundthreetotals[i]*1.5/3
  2392.       end
  2393.      @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
  2394.      @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
  2395.      @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
  2396.      @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
  2397.      Graphics.update
  2398.      sleep(1)
  2399.     end
  2400.     #Draw fourth round
  2401.     textpos.clear
  2402.     @sprites["textbitmap"].bitmap.clear
  2403.     textpos.push([_INTL("Fourth Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2404.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2405.     3.times do
  2406.       for i in 0..3
  2407.         @results[i]+=@roundfourtotals[i]*1.5/3
  2408.       end
  2409.      @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
  2410.      @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
  2411.      @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
  2412.      @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
  2413.      Graphics.update
  2414.      sleep(1)
  2415.     end
  2416.     #Draw fifth round
  2417.     textpos.clear
  2418.     @sprites["textbitmap"].bitmap.clear
  2419.     textpos.push([_INTL("Fifth Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2420.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2421.     3.times do
  2422.       for i in 0..3
  2423.         @results[i]+=@roundfivetotals[i]*1.5/3
  2424.       end
  2425.      @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
  2426.      @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
  2427.      @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
  2428.      @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
  2429.      Graphics.update
  2430.      sleep(1)
  2431.     end
  2432.     #draw Stars
  2433.     textpos.clear
  2434.     @sprites["textbitmap"].bitmap.clear
  2435.     textpos.push([_INTL("Stars Earned"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2436.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2437.     3.times do
  2438.       for i in 0..3
  2439.         @results[i]+=@newstars[i]*10/3
  2440.       end
  2441.      @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
  2442.      @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
  2443.      @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
  2444.      @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
  2445.      Graphics.update
  2446.      sleep(1)
  2447.     end
  2448.     winner=[@pkmn1total*1.5+@prelim1+@pkmn1stars*10,@pkmn2total*1.5+@prelim2+@pkmn2stars*10,@pkmn3total*1.5+@prelim3+@pkmn3stars*10,@pkmn4total*1.5+@prelim4+@pkmn4stars*10].sort.reverse
  2449.     win=(winner[0]==(@pkmn1total*1.5+@prelim1+@pkmn1stars*10))? @pkmn1:(winner[0]==(@pkmn2total*1.5+@prelim2+@pkmn2stars*10))? @pkmn2:(winner[0]==(@pkmn3total*1.5+@prelim3+@pkmn3stars*10))? @pkmn3:@pkmn4
  2450.     textpos.clear
  2451.     @sprites["textbitmap"].bitmap.clear
  2452.     textpos.push([(_INTL("{1} is the winner!",win.name)),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
  2453.     pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
  2454.     if win==@pkmn1
  2455.       @@won=true
  2456.       $Trainer.party[$game_variables[36]].giveRibbon(@ribbonnum) if !($Trainer.party[$game_variables[36]].hasRibbon?(@ribbonnum))
  2457.     end
  2458.     Graphics.update
  2459.     sleep(1)
  2460.     @pkmn1sprite.dispose
  2461.     @pkmn2sprite.dispose
  2462.     @pkmn3sprite.dispose
  2463.     @pkmn4sprite.dispose
  2464.     @sprites["overlay2"].bitmap.clear
  2465.   end
  2466. ################################################################################
  2467.  
  2468.   def won
  2469.     return @@won==true
  2470.   end
  2471.  
  2472. end
  2473.  
  2474. class PokeContest
  2475.   def initialize(scene)
  2476.     @scene=scene
  2477.   end
  2478.  
  2479.   def pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
  2480.     @scene.pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
  2481.     @scene.middleScene
  2482.     @scene.pbEndScene
  2483.     return @scene.won
  2484.   end
  2485. end
  2486.  
  2487.  
  2488. def pbContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
  2489.   scene=PokeContestScene.new
  2490.   screen=PokeContest.new(scene)
  2491.   return screen.pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
  2492. end
  2493.  
  2494.  
  2495. ################################################################################
  2496. #  Define Contest Combos here
  2497. ################################################################################
  2498.      #define all combos here.  first entry in array starts the combo, the rest are the options to follow it
  2499.      #name them by their name used in the game, not the internal name
  2500.      combo1=["Belly Drum","Rest"]
  2501.      combo2=["Calm Mind","Confusion","Dream Eater","Future Sight","Light Screen","Luster Purge","Meditate","Mist Ball","Psybeam","Psychic","Psycho Boost","Psywave","Reflect"]
  2502.      combo3=["Charge","Shock Wave","Spark","Thunder","Thunderbolt","Thunder Punch","Thunder Shock","Thunder Wave","Volt Tackle","Zap Cannon"]
  2503.      combo4=["Charm","Flatter","Growl","Rest","Tail Whip"]
  2504.      combo5=["Confusion","Future Sight","Kinesis","Psychic","Teleport"]
  2505.      combo6=["Curse","Destiny Bond","Grudge","Mean Look","Spite"]
  2506.      combo7=["Defense Curl","Rollout","Tackle"]
  2507.      combo8=["Dive","Surf"]
  2508.      combo9=["Double Team","Agility","Quick Attack","Teleport"]
  2509.      combo10=["Dragon Breath","Dragon Claw","Dragon Dance","Dragon Rage"]
  2510.      combo11=["Dragon Dance","Dragon Breath","Dragon Claw","Dragon Rage"]
  2511.      combo12=["Dragon Rage","Dragon Breath","Dragon Claw","Dragon Dance"]
  2512.      combo13=["Earthquake","Eruption","Fissure"]
  2513.      combo14=["Endure","Flail","Reversal"]
  2514.      combo15=["Fake Out","Arm Thrust","Feint Attack","Knock Off","Seismic Toss","Vital Throw"]
  2515.      combo16=["Fire Punch","Ice Punch","Thunder Punch"]
  2516.      combo17=["Focus Energy","Arm Thrust","Brick Break","Cross Chop","Double Edge","DynamicPunch","Focus Punch","Headbutt","Karate Chop","Sky Uppercut","Take Down"]
  2517.      combo18=["Growth","Absorb","Bullet Seed","Frenzy Plant","Giga Drain","Leech Seed","Magical Leaf","Mega Drain","Petal Dance","Razor Leaf","SolarBeam","Vine Whip"]
  2518.      combo19=["Hail","Aurora Beam","Blizzard","Haze","Ice Ball","Ice Beam","Icicle Spear","Icy Wind","Powder Snow","Sheer Cold","Weather Ball"]
  2519.      combo20=["Harden","Double Edge","Protect","Rollout","Tackle","Take Down"]
  2520.      combo21=["Horn Attack","Horn Drill","Fury Attack"]
  2521.      combo22=["Hypnosis","Dream Eater"]
  2522.      combo23=["Ice Punch","Fire Punch","Thunder Punch"]
  2523.      combo24=["Kinesis","Confusion","Future Sight","Psychic","Teleport"]
  2524.      combo25=["Leer","Bite","Feint Attack","Glare","Horn Attack","Scary Face","Scratch","Stomp","Tackle"]
  2525.      combo26=["Lock-On","Superpower","Thunder","Tri Attack","Zap Cannon"]
  2526.      combo27=["Mean Look","Destiny Bond","Perish Song"]
  2527.      combo28=["Metal Sound","Metal Claw"]
  2528.      combo29=["Mind Reader","DynamicPunch","Hi Jump Kick","Sheer Cold","Submission","Superpower"]
  2529.      combo30=["Mud Sport","Mud-Slap","Water Gun","Water Sport"]
  2530.      combo31=["Peck","Drill Peck","Fury Attack"]
  2531.      combo32=["Pound","Double Slap","Feint Attack","Slam"]
  2532.      combo33=["Powder Snow","Blizzard"]
  2533.      combo34=["Psychic","Confusion","Teleport","Future Sight","Kinesis"]
  2534.      combo35=["Rage","Leer","Scary Face","Thrash"]
  2535.      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"]
  2536.      combo37=["Rest","Sleep Talk","Snore"]
  2537.      combo38=["Rock Throw","Rock Slide","Rock Tomb"]
  2538.      combo39=["Sand-Attack","Mud-Slap"]
  2539.      combo40=["Sandstorm","Mud Shot","Mud-Slap","Mud Sport","Sand Tomb","Sand-Attack","Weather Ball"]
  2540.      combo41=["Scary Face","Bite","Crunch","Leer"]
  2541.      combo42=["Scratch","Fury Swipes","Slash"]
  2542.      combo43=["Sing","Perish Song","Refresh"]
  2543.      combo44=["Sludge","Sludge Bomb"]
  2544.      combo45=["Sludge Bomb","Sludge"]
  2545.      combo46=["Smog","Smokescreen"]
  2546.      combo47=["Stockpile","Spit Up","Swallow"]
  2547.      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"]
  2548.      combo49=["Surf","Dive"]
  2549.      combo50=["Sweet Scene","Poison Powder","Sleep Powder","Stun Spore"]
  2550.      combo51=["Swords Dance","Crabhammer","Crush Claw","Cut","False Swipe","Fury Cutter","Slash"]
  2551.      combo52=["Taunt","Counter","Detect","Mirror Coat"]
  2552.      combo53=["Thunder Punch","Fire Punch","Ice Punch"]
  2553.      combo54=["Vice Grip","Bind","Guillotine"]
  2554.      combo55=["Water Sport","Mud Sport","Refresh","Water Gun"]
  2555.      combo56=["Yawn","Rest","Slack Off"]
  2556.      #add more combos here
  2557.      #then add them to this array below
  2558.      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,
  2559.      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]
  2560.      
  2561. ################################################################################
  2562. # blank array to store moves to teach contest pokemon
  2563. ################################################################################
  2564. CONTESTMOVE2=[0,0,0,0]
  2565. CONTESTMOVE3=[0,0,0,0]
  2566. CONTESTMOVE4=[0,0,0,0]
  2567.  
  2568. def pbAddContestMove(poke,move1=0,move2=0,move3=0,move4=0)
  2569.   poketochange=[0,0,0,0]
  2570.   poketochange[0]=move1
  2571.   poketochange[1]=move2
  2572.   poketochange[2]=move3
  2573.   poketochange[3]=move4
  2574.   case poke
  2575.   when 2
  2576.     for i in 0..3
  2577.     CONTESTMOVE2[i]=poketochange[i]
  2578.     end
  2579.   when 3
  2580.     for i in 0..3
  2581.     CONTESTMOVE3[i]=poketochange[i]
  2582.     end
  2583.   when 4
  2584.     for i in 0..3
  2585.     CONTESTMOVE4[i]=poketochange[i]
  2586.     end
  2587.   end
  2588. end
  2589. ################################################################################
  2590. # nicknaming contest pokemon
  2591. ################################################################################
  2592. $CONTESTNAME2=""
  2593. $CONTESTNAME3=""
  2594. $CONTESTNAME4=""
  2595.  
  2596. def pbChangeContestName(poke,name="")
  2597.   if name !="" && name.length<16
  2598.      case poke
  2599.      when 2
  2600.        $CONTESTNAME2=name
  2601.      when 3
  2602.        $CONTESTNAME3=name
  2603.      when 4
  2604.        $CONTESTNAME4=name
  2605.      end
  2606.    end  
  2607. end  
  2608.  
  2609. ################################################################################
  2610. # Animation player for contest
  2611. ################################################################################
  2612. class PBAnimationPlayerContest
  2613.   attr_accessor :looping
  2614.   MAXSPRITES=30
  2615.  
  2616.   def initialize(animation,user,target,usersprite,targetsprite,scene=nil,ineditor=false)
  2617.     @animation=animation
  2618.     @user=user
  2619.     @usersprite=usersprite
  2620.     @targetsprite=targetsprite
  2621.     @userbitmap=(@usersprite && @usersprite.bitmap) ? @usersprite.bitmap : nil # not to be disposed
  2622.     @targetbitmap=(@targetsprite && @targetsprite.bitmap) ? @targetsprite.bitmap : nil # not to be disposed
  2623.     @scene=scene
  2624.     @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  2625.     @viewport.z=99999
  2626.     @ineditor=ineditor
  2627.     @looping=false
  2628.     @animbitmap=nil # Animation sheet graphic
  2629.     @frame=-1
  2630.     @srcLine=nil
  2631.     @dstLine=nil
  2632.     @userOrig=getSpriteCenter(@usersprite)
  2633.     @targetOrig=getSpriteCenter(@targetsprite)
  2634.     @animsprites=[]
  2635.     @animsprites[0]=@usersprite
  2636.     @animsprites[1]=@targetsprite
  2637.     for i in 2...MAXSPRITES
  2638.       @animsprites[i]=Sprite.new(@viewport)
  2639.       @animsprites[i].bitmap=nil
  2640.       @animsprites[i].visible=false
  2641.     end
  2642.    
  2643.     @bgColor=ColoredPlane.new(Color.new(0,0,0),@viewport)
  2644.     @bgColor.borderX=64 if ineditor
  2645.     @bgColor.borderY=64 if ineditor
  2646.     @bgColor.z=2
  2647.     @bgColor.opacity=0
  2648.     @bgColor.refresh
  2649.     @bgGraphic=AnimatedPlane.new(@viewport)
  2650.     @bgGraphic.setBitmap(nil)
  2651.     @bgGraphic.borderX=64 if ineditor
  2652.     @bgGraphic.borderY=64 if ineditor
  2653.     @bgGraphic.z=2
  2654.     @bgGraphic.opacity=0
  2655.     @bgGraphic.refresh
  2656.     @oldbg=[]
  2657.    
  2658.     @foColor=ColoredPlane.new(Color.new(0,0,0),@viewport)
  2659.     @foColor.borderX=64 if ineditor
  2660.     @foColor.borderY=64 if ineditor
  2661.     @foColor.z=38
  2662.     @foColor.opacity=0
  2663.     @foColor.refresh
  2664.     @foGraphic=AnimatedPlane.new(@viewport)
  2665.     @foGraphic.setBitmap(nil)
  2666.     @foGraphic.borderX=64 if ineditor
  2667.     @foGraphic.borderY=64 if ineditor
  2668.     @foGraphic.z=38
  2669.     @foGraphic.opacity=0
  2670.     @foGraphic.refresh
  2671.     @oldfo=[]
  2672.   end
  2673.  
  2674.   def dispose
  2675.     @animbitmap.dispose if @animbitmap
  2676.     for i in 2...MAXSPRITES
  2677.       @animsprites[i].dispose if @animsprites[i]
  2678.     end
  2679.     @bgGraphic.dispose
  2680.     @bgColor.dispose
  2681.     @foGraphic.dispose
  2682.     @foColor.dispose
  2683.   end
  2684.  
  2685.   def start
  2686.     @frame=0
  2687.   end
  2688.  
  2689.   def playing?
  2690.     return @frame>=0
  2691.   end
  2692.  
  2693.   def setLineTransform(x1,y1,x2,y2,x3,y3,x4,y4)
  2694.     @srcLine=[x1,y1,x2,y2]
  2695.     @dstLine=[x3,y3,x4,y4]
  2696.   end
  2697.  
  2698.   def update
  2699.     return if @frame<0
  2700.     if (@frame>>1) >= @animation.length
  2701.       @frame=(@looping) ? 0 : -1
  2702.       if @frame<0
  2703.         @animbitmap.dispose if @animbitmap
  2704.         @animbitmap=nil
  2705.         return
  2706.       end
  2707.     end
  2708.     if !@animbitmap || @animbitmap.disposed?
  2709.       @animbitmap=AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic,
  2710.          @animation.hue).deanimate
  2711.       for i in 0...MAXSPRITES
  2712.         @animsprites[i].bitmap=@animbitmap if @animsprites[i]
  2713.       end
  2714.     end
  2715.     @bgGraphic.update
  2716.     @bgColor.update
  2717.     @foGraphic.update
  2718.     @foColor.update
  2719.     if (@frame&1)==0
  2720.       thisframe=@animation[@frame>>1]
  2721.       # Make all cel sprites invisible
  2722.       for i in 0...MAXSPRITES
  2723.         @animsprites[i].visible=false if @animsprites[i]
  2724.       end
  2725.       # Set each cel sprite acoordingly
  2726.       for i in 0...thisframe.length
  2727.         cel=thisframe[i]
  2728.         next if !cel
  2729.         sprite=@animsprites[i]
  2730.         next if !sprite
  2731.         # Set cel sprite's graphic
  2732.         if cel[AnimFrame::PATTERN]==-1
  2733.           sprite.bitmap=@userbitmap
  2734.         elsif cel[AnimFrame::PATTERN]==-2
  2735.           sprite.bitmap=@targetbitmap
  2736.         else
  2737.           sprite.bitmap=@animbitmap
  2738.         end
  2739.         cel[AnimFrame::MIRROR]=1
  2740.         # Apply settings to the cel sprite
  2741.         pbSpriteSetAnimFrame(sprite,cel,@usersprite,@targetsprite)
  2742.         case cel[AnimFrame::FOCUS]
  2743.           when 1   # Focused on target
  2744.             sprite.x=cel[AnimFrame::X]+@targetOrig[0]-PokeBattle_SceneConstants::FOCUSTARGET_X
  2745.             sprite.y=cel[AnimFrame::Y]+@targetOrig[1]-PokeBattle_SceneConstants::FOCUSTARGET_Y
  2746.           when 2   # Focused on user
  2747.             sprite.x=cel[AnimFrame::X]+@userOrig[0]-PokeBattle_SceneConstants::FOCUSUSER_X
  2748.             sprite.y=cel[AnimFrame::Y]+@userOrig[1]-PokeBattle_SceneConstants::FOCUSUSER_Y
  2749.           when 3   # Focused on user and target
  2750.             if @srcLine && @dstLine
  2751.               point=transformPoint(
  2752.                  @srcLine[0],@srcLine[1],@srcLine[2],@srcLine[3],
  2753.                  @dstLine[0],@dstLine[1],@dstLine[2],@dstLine[3],
  2754.                  sprite.x,sprite.y)
  2755.               sprite.x=point[0]
  2756.               sprite.y=point[1]
  2757.             end
  2758.         end
  2759.         sprite.x+=64 if @ineditor
  2760.         sprite.y+=64 if @ineditor
  2761.       end
  2762.       # Play timings
  2763.       @animation.playTiming(@frame>>1,@bgGraphic,@bgColor,@foGraphic,@foColor,@oldbg,@oldfo,@user)
  2764.     end
  2765.     @frame+=1
  2766.   end
  2767. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement