Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PokeContestScene
- attr_reader :name
- attr_accessor :selected
- attr_reader :hearts
- def initialize
- @sprites={}
- @heartsprites={}
- @@won=false
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @viewport2=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport2.z=99999+2
- @sprites["background"]=IconSprite.new(0,0,@viewport)
- @sprites["background"].setBitmap("Graphics/Pictures/Contest/contestbg")
- end
- #CONTESTCOMBOS are defined in the bottom of this script
- def pbCheckforCombos
- case @currentpoke
- when @pkmn1
- oldmove=@pkmn1lastmove
- when @pkmn2
- oldmove=@pkmn2lastmove
- when @pkmn3
- oldmove=@pkmn3lastmove
- when @pkmn4
- oldmove=@pkmn4lastmove
- end
- for j in 0..CONTESTCOMBOS.length-1
- if oldmove==CONTESTCOMBOS[j][0]
- for i in 1..CONTESTCOMBOS[j].length-1
- if @currentmovename==CONTESTCOMBOS[j][i]
- return true
- end
- end
- end
- end
- return false
- end
- def update
- pbUpdateSpriteHash(@sprites)
- end
- def pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
- pbBGMPlay("021-Field04") #Change this for different music
- @contestover=false #ends when set to true
- @difficulty=difficulty
- @ribbonnum=ribbonnum #ribbon number given if won
- case $game_variables[35]
- when 1
- @contestType="Cool"
- when 2
- @contestType="Beauty"
- when 3
- @contestType="Cute"
- when 4
- @contestType="Smart"
- when 5
- @contestType="Tough"
- else
- @contestType="Cool"
- end
- @pkmn1=$Trainer.party[$game_variables[36]]
- @pkmn2=PokeBattle_Pokemon.new(opponent1,opponent1level,$Trainer)
- @pkmn3=PokeBattle_Pokemon.new(opponent2,opponent2level,$Trainer)
- @pkmn4=PokeBattle_Pokemon.new(opponent3,opponent3level,$Trainer)
- #teach opponent pokemon new moves if defined
- for i in 0...CONTESTMOVE2.length
- @pkmn2.pbLearnMove(CONTESTMOVE2[i]) if CONTESTMOVE2[i]!=0
- end
- for i in 0...CONTESTMOVE3.length
- @pkmn3.pbLearnMove(CONTESTMOVE3[i]) if CONTESTMOVE3[i]!=0
- end
- for i in 0...CONTESTMOVE4.length
- @pkmn4.pbLearnMove(CONTESTMOVE4[i]) if CONTESTMOVE4[i]!=0
- end
- #nicknames for contest pokemon
- @pkmn2.name=$CONTESTNAME2 if $CONTESTNAME2 !=""
- @pkmn3.name=$CONTESTNAME3 if $CONTESTNAME3 !=""
- @pkmn4.name=$CONTESTNAME4 if $CONTESTNAME4 !=""
- @pkmn1total=0
- @pkmn2total=0
- @pkmn3total=0
- @pkmn4total=0
- @pkmn1DoubleNext=false
- @pkmn2DoubleNext=false
- @pkmn3DoubleNext=false
- @pkmn4DoubleNext=false
- @pkmn1MissTurn=false
- @pkmn2MissTurn=false
- @pkmn3MissTurn=false
- @pkmn4MissTurn=false
- @pkmn1nomoremoves=false
- @pkmn2nomoremoves=false
- @pkmn3nomoremoves=false
- @pkmn4nomoremoves=false
- @applause=0
- @pkmn1stars=0
- @pkmn2stars=0
- @pkmn3stars=0
- @pkmn4stars=0
- @pkmn1hearts=0
- @pkmn2hearts=0
- @pkmn3hearts=0
- @pkmn4hearts=0
- @stars=[@pkmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
- pbPreliminaryScene #extra points for scarves, points gained by pokeblocks and such done here
- #the "preliminary judging" seen before this starts is just for show, it doesn't do anything then
- pbResetContestMoveEffects
- pbResetHearts
- @round=0
- if !($DEBUG && Input.press?(Input::CTRL)) #Skip all rounds if pressing Control in Debug mode
- @round=1
- pbTurn(@round)
- if !($DEBUG && Input.press?(Input::CTRL))
- @round=2
- pbTurn(@round)
- @round=3
- pbTurn(@round)
- @round=4
- pbTurn(@round)
- @round=5
- pbTurn(@round)
- else
- pbResetHearts
- pbDebugTotals(1)
- end
- else
- @prelim1+=90
- pbResetHearts
- pbDebugTotals(6)
- end
- pbDisposeSprite(@sprites,"overlay2") #clear overlay to prep for end scene
- # End scene
- @sprites["background"]=IconSprite.new(0,0,@viewport)
- @sprites["background"].setBitmap("Graphics/Pictures/Contest/contestbg")
- pbResultsScene
- $game_variables[35]=0 #reset variables
- $game_variables[36]=0
- @contestover=true #allows scene to exit loop and end
- end
- ###############################################################################
- # Main round processing function
- ###############################################################################
- def pbTurn(turnnumber)
- Graphics.update
- @atself=false
- @priorhearts=0
- if @round==1
- @sprites["Judge"]=IconSprite.new(0,0,@viewport)
- @sprites["Judge"].setBitmap("Graphics/Characters/trainer017")
- Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Welcome to today's {1} Type Pokemon Contest\nIt's heartwarming to see all these young trainers here to show off their Pokemon's skills!",@contestType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- Kernel.pbCustomMessage(_INTL("\\l[3]\\c[1]I'm going to be the judge for this competition, so let's get started!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisposeSprite(@sprites,"Judge")
- sleep(1.0/3.0)
- Graphics.update
- end
- if @round==1 #
- pbFindFastestOrderRanking #
- else #determine order
- pbOrder #
- end #
- pbResetContestMoveEffects
- pbDrawText
- roundfile=(turnnumber==1)? "Graphics/Pictures/Contest/Roundone":(turnnumber==2)?"Graphics/Pictures/Contest/Roundtwo":(turnnumber==3)?"Graphics/Pictures/Contest/Roundthree":(turnnumber==4)?"Graphics/Pictures/Contest/Roundfour":"Graphics/Pictures/Contest/Roundfive"
- @sprites["Round"]=IconSprite.new(0,0,@viewport)
- @sprites["Round"].setBitmap(roundfile)
- sleep(1.0/7.0)
- Graphics.update
- roundupdown=0
- for i in 0...9
- if roundupdown==0 or roundupdown==1 or roundupdown==4 or roundupdown==5 or roundupdown==8 or roundupdown==9
- @sprites["Round"].y+=6
- else
- @sprites["Round"].y-=6
- end
- roundupdown+=1
- Graphics.update
- sleep(1.0/7.0)
- end
- sleep(1)
- pbDisposeSprite(@sprites,"Round")
- pbMoveButtons
- @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
- pbSetSystemFont(@sprites["overlay"].bitmap)
- pbDisplayFastest
- @sprites["opponent"]=IconSprite.new(50,30,@viewport) #
- @sprites["opponent"].setBitmap("Graphics/Battler/000") #invisible sprite to serve as target for animations
- @sprites["opponent"].visible=false #
- Graphics.update
- Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Alright {1}, let's see what you can do!",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @currentpos=1
- @currentpoke=@pokeorder[0]
- if @currentpoke==@pkmn1 #
- i=@moveselection #
- else #Determine which move to use
- i=pbAI(@pokeorder[0],@difficulty) # AI for opponents
- end #
- movedata=PBMoveData.new(@pokeorder[0].moves[i].id)
- movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
- @currentmovename=PBMoves.getName(@pokeorder[0].moves[i].id)
- sleep(1)
- for i in 1..PBContestMoves.maxValue #
- name=PBContestMoves.getName(i) #
- if @currentmovename==name # Match the pokemon's move with the equivalent from contestmoves.txt
- @currentmove=getID(PBContestMoves,i) #
- @currentmove1=getID(PBMoves,i) # Get actual ID to display proper move animation
- end
- end
- (movedata.target==PBTargets::User)? @atself=true :@atself=false
- contestmovedata=PBContestMoveData.new(@currentmove) #Find the moves contest data
- @currenthearts=contestmovedata.hearts
- moveType=contestmovedata.contestType
- pbmoveType(moveType)
- if pbNoMore==false #skip the move processing if nomore moves is true
- if pbMissTurn==false #skip move processing if it misses this turn
- if pbDoubleNext==true #check for double hearts
- @currenthearts*=2
- pbReverseDoubleNext
- end
- if @nervous[@currentpos-1]==true
- Kernel.pbCustomMessage(_INTL("\\\l[3]{1} is nervous.",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- if rand(100)<30 #check for nervousness, 30% chance
- Kernel.pbCustomMessage(_INTL("\\\l[3]{1} was too nervous to move!",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[0].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[0].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- pbReverseMissTurn #change miss turn variable back after missing turn
- end
- end
- pbFunctionsAdjustHearts #
- pbDisplayAddingPositiveHearts
- if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
- @currenthearts-=1
- Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
- pbDecreaseHearts(@currentpoke,@currentpos,selfjam="notnil")
- end
- if @round !=1 && pbCheckforCombos==true
- @currenthearts=5
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisplayAddingPositiveHearts
- pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
- end
- pbAssignLastMove
- @lastmoveType=@moveType
- pbCrowd
- Graphics.update
- sleep(1.0/10.0)
- Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Good job {1}, now onto the next pokemon!",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- sleep(1.0/10.0)
- pbDisposeSprite(@sprites,"pokemon1")
- Graphics.update
- sleep(1.0/10.0)
- Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisplaySecondFastest
- Graphics.update
- sleep(1.0/10.0)
- @currentpos=2
- @currentpoke=@pokeorder[1]
- if @currentpoke==@pkmn1
- i=@moveselection
- else
- i=pbAI(@pokeorder[1],@difficulty)
- end
- movedata=PBMoveData.new(@pokeorder[1].moves[i].id)
- movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
- @currentmovename=PBMoves.getName(@pokeorder[1].moves[i].id)
- sleep(1)
- for i in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(i)
- if @currentmovename==name
- @currentmove=getID(PBContestMoves,i)
- @currentmove1=getID(PBMoves,i)
- end
- end
- (movedata.target==PBTargets::User)? @atself=true :@atself=false
- contestmovedata=PBContestMoveData.new(@currentmove)
- @currenthearts=contestmovedata.hearts
- moveType=contestmovedata.contestType
- pbmoveType(moveType)
- if pbNoMore==false #skip the move processing if nomore moves is true
- if pbMissTurn==false #skip move processing if it misses this turn
- if pbDoubleNext==true #check for double hearts
- @currenthearts*=2
- pbReverseDoubleNext
- end
- if @nervous[@currentpos-1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- if rand(100)<30 #check for nervousness, 30% chance
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[1].name))
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[1].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[1].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- pbReverseMissTurn #change miss turn variable back after missing turn
- end
- end
- pbFunctionsAdjustHearts
- pbDisplayAddingPositiveHearts
- if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
- @currenthearts-=1
- Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
- pbDecreaseHearts(@currentpoke,@currentpos,selfjam="notnil")
- end
- if @round !=1 && pbCheckforCombos==true
- @currenthearts=5
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisplayAddingPositiveHearts
- pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
- end
- pbAssignLastMove
- @lastmoveType=@moveType
- pbCrowd
- Graphics.update
- sleep(1.0/10.0)
- pbDisposeSprite(@sprites,"pokemon2")
- Graphics.update
- sleep(1.0/10.0)
- Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisplayThirdFastest
- Graphics.update
- sleep(1.0/10.0)
- @currentpos=3
- @currentpoke=@pokeorder[2]
- if @currentpoke==@pkmn1
- i=@moveselection
- else
- i=pbAI(@pokeorder[2],@difficulty)
- end
- movedata=PBMoveData.new(@pokeorder[2].moves[i].id)
- movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
- @currentmovename=PBMoves.getName(@pokeorder[2].moves[i].id)
- sleep(1)
- for i in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(i)
- if @currentmovename==name
- @currentmove=getID(PBContestMoves,i)
- @currentmove1=getID(PBMoves,i)
- end
- end
- (movedata.target==PBTargets::User)? @atself=true :@atself=false
- contestmovedata=PBContestMoveData.new(@currentmove)
- @currenthearts=contestmovedata.hearts
- moveType=contestmovedata.contestType
- pbmoveType(moveType)
- if pbNoMore==false #skip the move processing if nomore moves is true
- if pbMissTurn==false #skip move processing if it misses this turn
- if pbDoubleNext==true #check for double hearts
- @currenthearts*=2
- pbReverseDoubleNext
- end
- if @nervous[@currentpos-1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- if rand(100)<30 #check for nervousness, 30% chance
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[2].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[2].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- pbReverseMissTurn #change miss turn variable back after missing turn
- end
- end
- pbFunctionsAdjustHearts #
- pbDisplayAddingPositiveHearts
- if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
- @currenthearts-=1
- Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
- pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,selfjam="notnil")
- end
- if @round !=1 && pbCheckforCombos==true
- @currenthearts=5
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisplayAddingPositiveHearts
- pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
- end
- pbAssignLastMove
- @lastmoveType=@moveType
- pbCrowd
- Graphics.update
- sleep(1.0/10.0)
- pbDisposeSprite(@sprites,"pokemon3")
- Graphics.update
- sleep(1.0/10.0)
- Kernel.pbCustomMessage(_INTL("\\l[3]Judge: \\c[1]Next up we have {1}!",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisplayFourthFastest
- Graphics.update
- sleep(1.0/10.0)
- @currentpos=4
- @currentpoke=@pokeorder[3]
- if @currentpoke==@pkmn1
- i=@moveselection
- else
- i=pbAI(@pokeorder[3],@difficulty)
- end
- movedata=PBMoveData.new(@pokeorder[3].moves[i].id)
- movedata=PBMoveData.new(@pokeorder[0].moves[0].id) if movedata.id<=0
- @currentmovename=PBMoves.getName(@pokeorder[3].moves[i].id)
- sleep(1)
- for i in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(i)
- if @currentmovename==name
- @currentmove=getID(PBContestMoves,i)
- @currentmove1=getID(PBMoves,i)
- end
- end
- (movedata.target==PBTargets::User)? @atself=true :@atself=false
- contestmovedata=PBContestMoveData.new(@currentmove)
- @currenthearts=contestmovedata.hearts
- moveType=contestmovedata.contestType
- pbmoveType(moveType)
- if pbNoMore==false #skip the move processing if nomore moves is true
- if pbMissTurn==false #skip move processing if it misses this turn
- if pbDoubleNext==true #check for double hearts
- @currenthearts*=2
- pbReverseDoubleNext
- end
- if @nervous[@currentpos-1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} is nervous.",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- if rand(100)<30 #check for nervousness, 30% chance
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} was too nervous to move!",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[3].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} used {2}!",@pokeorder[3].name,@currentmovename),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbAnimation(@currentmove1,0,1,hitnum=0)
- end
- else
- pbReverseMissTurn #change miss turn variable back after missing turn
- end
- end
- pbFunctionsAdjustHearts #
- pbDisplayAddingPositiveHearts
- if pbCheckLast && @currentfunction !=15 && @round !=1 && pbNoMore==false && pbMissTurn==false
- @currenthearts-=1
- Kernel.pbCustomMessage(_INTL("\\l[3]The judge looked at {1} expectantly!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbJam(1,@pokeorder[@currentpos-1],@currentpos-1)
- pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,selfjam="notnil")
- end
- if @round !=1 && pbCheckforCombos==true
- @currenthearts=5
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} really caught the judges attention!",@pokeorder[@currentpos-1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- pbDisplayAddingPositiveHearts
- pbDecreaseStarGraphics(@currentpos-1,1,decrease=false)
- end
- pbAssignLastMove
- @lastmoveType=@moveType
- pbCrowd
- Graphics.update
- sleep(1.0/10.0)
- pbDisposeSprite(@sprites,"pokemon4")
- pbDisposeSprite(@sprites,"opponent")
- pbResetHearts
- Graphics.update
- end
- ###############################################################################
- # Misc. Functions
- ###############################################################################
- def pbAssignLastMove
- case @currentpoke
- when @pkmn1
- @pkmn1lastmove=@currentmovename
- when @pkmn2
- @pkmn2lastmove=@currentmovename
- when @pkmn3
- @pkmn3lastmove=@currentmovename
- else
- @pkmn4lastmove=@currentmovename
- end
- end
- def pbCheckLast
- case @currentpoke
- when @pkmn1
- if @pkmn1lastmove
- if @currentmovename==@pkmn1lastmove
- return true
- else
- return false
- end
- end
- when @pkmn2
- if @pkmn2lastmove
- if @currentmovename==@pkmn2lastmove
- return true
- else
- return false
- end
- end
- when @pkmn3
- if @pkmn3lastmove
- if @currentmovename==@pkmn3lastmove
- return true
- else
- return false
- end
- end
- when @pkmn4
- if @pkmn4lastmove
- if @currentmovename==@pkmn4lastmove
- return true
- else
- return false
- end
- end
- end
- end
- def pbmoveType(moveType)
- case moveType
- when 0
- @moveType="Cool"
- when 1
- @moveType="Beauty"
- when 2
- @moveType="Cute"
- when 3
- @moveType="Smart"
- when 4
- @moveType="Tough"
- end
- end
- def pbDrawText
- @sprites["overlay2"].bitmap.clear if @sprites["overlay2"]
- #change graphic indicating what position the player's pokemon is at
- if !@sprites["playerspokebg"]
- @sprites["playerspokebg"]=IconSprite.new(347,96,@viewport)
- @sprites["playerspokebg"].setBitmap("Graphics/Pictures/Contest/playerspoke")
- end
- for i in 0..3
- if @pokeorder[i]==@pkmn1
- @sprites["playerspokebg"].y=96*i
- end
- end
- @sprites["overlay2"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport) if !@sprites["overlay2"]
- pbSetSystemFont(@sprites["overlay2"].bitmap)
- overlay=@sprites["overlay2"].bitmap
- overlay.clear
- pokeone=_INTL("{1}",@pokeorder[0].name)
- poketwo=_INTL("{1}",@pokeorder[1].name)
- pokethree=_INTL("{1}",@pokeorder[2].name)
- pokefour=_INTL("{1}",@pokeorder[3].name)
- baseColor=Color.new(72,72,72)
- shadowColor=Color.new(160,160,160)
- textPositions=[
- [pokeone,353,5,false,baseColor,shadowColor],
- [poketwo,353,100,false,baseColor,shadowColor],
- [pokethree,353,195,false,baseColor,shadowColor],
- [pokefour,353,290,false,baseColor,shadowColor],
- ]
- pbDrawTextPositions(overlay,textPositions)
- end
- def pbNoMore #checks if pokemon can use moves
- case @currentpoke
- when @pkmn1
- if @pkmn1nomoremoves==true
- return true
- else
- return false
- end
- when @pkmn2
- if @pkmn2nomoremoves==true
- return true
- else
- return false
- end
- when @pkmn3
- if @pkmn3nomoremoves==true
- return true
- else
- return false
- end
- when @pkmn4
- if @pkmn4nomoremoves==true
- return true
- else
- return false
- end
- else
- return false
- end
- end
- def pbMissTurn #Checks if pokemon misses this turn
- case @currentpoke
- when @pkmn1
- if @pkmn1MissTurn==true
- return true
- else
- return false
- end
- when @pkmn2
- if @pkmn2MissTurn==true
- return true
- else
- return false
- end
- when @pkmn3
- if @pkmn3MissTurn==true
- return true
- else
- return false
- end
- when @pkmn4
- if @pkmn4MissTurn==true
- return true
- else
- return false
- end
- else
- return false
- end
- end
- def pbDoubleNext #Check if it should double hearts
- case @currentpoke
- when @pkmn1
- if @pkmn1DoubleNext==true
- return true
- else
- return false
- end
- when @pkmn2
- if @pkmn2DoubleNext==true
- return true
- else
- return false
- end
- when @pkmn3
- if @pkmn3DoubleNext==true
- return true
- else
- return false
- end
- when @pkmn4
- if @pkmn4DoubleNext==true
- return true
- else
- return false
- end
- else
- return false
- end
- end
- def pbSetNoMoreMoves
- case @currentpoke
- when @pkmn1
- @pkmn1nomoremoves=true
- when @pkmn2
- @pkmn2nomoremoves=true
- when @pkmn3
- @pkmn3nomoremoves=true
- when @pkmn4
- @pkmn4nomoremoves=true
- end
- end
- def pbSetMissTurn
- case @currentpoke
- when @pkmn1
- @pkmn1MissTurn=true
- when @pkmn2
- @pkmn2MissTurn=true
- when @pkmn3
- @pkmn3MissTurn=true
- when @pkmn4
- @pkmn4MissTurn=true
- end
- end
- def pbSetDoubleNext
- case @currentpoke
- when @pkmn1
- @pkmn1DoubleNext=true
- when @pkmn2
- @pkmn2DoubleNext=true
- when @pkmn3
- @pkmn3DoubleNext=true
- when @pkmn4
- @pkmn4DoubleNext=true
- end
- end
- def pbReverseMissTurn
- case @currentpoke
- when @pkmn1
- @pkmn1MissTurn=false
- when @pkmn2
- @pkmn2MissTurn=false
- when @pkmn3
- @pkmn3MissTurn=false
- when @pkmn4
- @pkmn4MissTurn=false
- end
- end
- def pbReverseDoubleNext
- case @currentpoke
- when @pkmn1
- @pkmn1DoubleNext=false
- when @pkmn2
- @pkmn2DoubleNext=false
- when @pkmn3
- @pkmn3DoubleNext=false
- when @pkmn4
- @pkmn4DoubleNext=false
- end
- end
- ###############################################################################
- # Heart Graphic Functions
- ###############################################################################
- def pbDisplayAddingPositiveHearts
- case @currentpoke
- when @pkmn1
- for i in 0...@currenthearts
- @pkmn1hearts+=1
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn1hearts)if @pkmn1hearts<21
- Graphics.update
- sleep(1.0/7.0)
- @heartsprites["firstpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
- @heartsprites["firstpokehearts"].setBitmap(heartfile)
- end
- @priorhearts=@pkmn1hearts
- when @pkmn2
- for i in 0...@currenthearts
- @pkmn2hearts+=1
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn2hearts)if @pkmn2hearts<21
- Graphics.update
- sleep(1.0/7.0)
- @heartsprites["secondpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
- @heartsprites["secondpokehearts"].setBitmap(heartfile)
- end
- @priorhearts=@pkmn2hearts
- when @pkmn3
- for i in 0...@currenthearts
- @pkmn3hearts+=1
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn3hearts)if @pkmn3hearts<21
- Graphics.update
- sleep(1.0/7.0)
- @heartsprites["thirdpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
- @heartsprites["thirdpokehearts"].setBitmap(heartfile)
- end
- @priorhearts=@pkmn3hearts
- when @pkmn4
- for i in 0...@currenthearts
- @pkmn4hearts+=1
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn4hearts)if @pkmn4hearts<21
- Graphics.update
- sleep(1.0/7.0)
- @heartsprites["fourthpokehearts"]=IconSprite.new(399,45+((@currentpos-1)*96),@viewport)
- @heartsprites["fourthpokehearts"].setBitmap(heartfile)
- end
- @priorhearts=@pkmn4hearts
- end
- end
- def pbDecreaseHearts(target,position,selfjam=nil)
- if selfjam==nil
- if @currentjam==1
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} looked down out of distraction!",target.name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} couldn't help leaping up!",target.name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- end
- end
- case target
- when @pkmn1
- @pkmn1jam*=2 if @easilystartled[position-1]==true
- for i in 0...@pkmn1jam
- @pkmn1hearts -= 1
- if @pkmn1hearts == 0
- pbDisposeSprite(@heartsprites,"firstpokehearts")
- @heartsprites["firstpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
- end
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn1hearts) if @pkmn1hearts >= 0 && @pkmn1hearts<21
- heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn1hearts.abs) if @pkmn1hearts < 0 && @pkmn1hearts>-21
- @heartsprites["firstpokehearts"].setBitmap(heartfile)
- sleep(1.0/7.0)
- Graphics.update
- end
- @priorhearts=@pkmn1hearts
- when @pkmn2
- @pkmn2jam*=2 if @easilystartled[position-1]==true
- for i in 0...@pkmn2jam
- @pkmn2hearts -= 1
- if @pkmn2hearts == 0
- pbDisposeSprite(@heartsprites,"secondpokehearts")
- @heartsprites["secondpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
- end
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn2hearts) if @pkmn2hearts >= 0 && @pkmn2hearts<21
- heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn2hearts.abs) if @pkmn2hearts < 0 && @pkmn2hearts>-21
- @heartsprites["secondpokehearts"].setBitmap(heartfile)
- sleep(1.0/7.0)
- Graphics.update
- end
- @priorhearts=@pkmn2hearts
- when @pkmn3
- @pkmn3jam*=2 if @easilystartled[position-1]==true
- for i in 0...@pkmn3jam
- @pkmn3hearts -= 1
- if @pkmn3hearts == 0
- pbDisposeSprite(@heartsprites,"thirdpokehearts")
- @heartsprites["thirdpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
- end
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn3hearts) if @pkmn3hearts >= 0 && @pkmn3hearts<21
- heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn3hearts.abs) if @pkmn3hearts < 0 && @pkmn3hearts>-21
- @heartsprites["thirdpokehearts"].setBitmap(heartfile)
- sleep(1.0/7.0)
- Graphics.update
- end
- @priorhearts=@pkmn3hearts
- when @pkmn4
- @pkmn4jam*=2 if @easilystartled[position-1]==true
- for i in 0...@pkmn4jam
- @pkmn4hearts -= 1
- if @pkmn4hearts == 0
- pbDisposeSprite(@heartsprites,"fourthpokehearts")
- @heartsprites["fourthpokehearts"]=IconSprite.new(399,45+((position-1)*96),@viewport)
- end
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",@pkmn4hearts) if @pkmn4hearts >= 0 && @pkmn4hearts<21
- heartfile=sprintf("Graphics/Pictures/Contest/negaheart%d",@pkmn4hearts.abs) if @pkmn4hearts < 0 && @pkmn4hearts>-21
- @heartsprites["fourthpokehearts"].setBitmap(heartfile)
- sleep(1.0/7.0)
- Graphics.update
- end
- @priorhearts=@pkmn4hearts
- end
- end
- ###############################################################################
- # Get rid of hearts graphics at end round, and add up heart totals
- ###############################################################################
- def pbResetHearts
- pbFadeOutAndHide(@heartsprites)
- Graphics.update
- pbDisposeSprite(@heartsprites,"firstpokehearts")
- pbDisposeSprite(@heartsprites,"secondpokehearts")
- pbDisposeSprite(@heartsprites,"thirdpokehearts")
- pbDisposeSprite(@heartsprites,"fourthpokehearts")
- @pkmn1total+=@pkmn1hearts
- @pkmn2total+=@pkmn2hearts
- @pkmn3total+=@pkmn3hearts
- @pkmn4total+=@pkmn4hearts
- @roundonetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==1
- @roundtwototals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==2
- @roundthreetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==3
- @roundfourtotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==4
- @roundfivetotals=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total] if @round==5
- @pkmn1hearts=0
- @pkmn2hearts=0
- @pkmn3hearts=0
- @pkmn4hearts=0
- Graphics.update
- sleep(1/2)
- end
- def pbDebugTotals(round) #random assortment of numbers, ensuring your pokemon wins. Intended to be used in debugging the end scene
- @roundonetotals=[20,rand(10),rand(10),rand(10)] if round>0
- @roundtwototals=[20,rand(10),rand(10),rand(10)]
- @roundthreetotals=[20,rand(10),rand(10),rand(10)]
- @roundfourtotals=[20,rand(10),rand(10),rand(10)]
- @roundfivetotals=[20,rand(10),rand(10),rand(10)]
- @pkmn1total=(@roundonetotals[0]+@roundtwototals[0]+@roundthreetotals[0]+@roundfourtotals[0]+@roundfivetotals[0])
- @pkmn2total=(@roundonetotals[1]+@roundtwototals[1]+@roundthreetotals[1]+@roundfourtotals[1]+@roundfivetotals[1])
- @pkmn3total=(@roundonetotals[2]+@roundtwototals[2]+@roundthreetotals[2]+@roundfourtotals[2]+@roundfivetotals[2])
- @pkmn4total=(@roundonetotals[3]+@roundtwototals[3]+@roundthreetotals[3]+@roundfourtotals[3]+@roundfivetotals[3])
- end
- ###############################################################################
- # Determines order for first round, goes by base speed
- ###############################################################################
- def pbFindFastestOrderRanking #Finds the fastest pokemon in the contest
- dexdata=pbOpenDexData
- pbDexDataOffset(dexdata,@pkmn1.species,13)
- basespeed1=dexdata.fgetb
- pokespeed1=basespeed1
- pbDexDataOffset(dexdata,@pkmn2.species,13)
- basespeed2=dexdata.fgetb
- pokespeed2=basespeed2
- pbDexDataOffset(dexdata,@pkmn3.species,13)
- basespeed3=dexdata.fgetb
- pokespeed3=basespeed3
- pbDexDataOffset(dexdata,@pkmn4.species,13)
- basespeed4=dexdata.fgetb
- pokespeed4=basespeed4
- dexdata.close
- fastest = [basespeed1, basespeed2, basespeed3, basespeed4]
- fastest=fastest.sort.reverse
- neworder=[]
- first=(fastest[0]==pokespeed1)? @pkmn1 : ((fastest[0]==pokespeed2) ? @pkmn2 : ((fastest[0]==pokespeed3)? @pkmn3 : @pkmn4))
- neworder.push(first)
- second =(fastest[1]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[1]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[1]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
- neworder.push(second)
- third =(fastest[2]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[2]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[2]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
- neworder.push(third)
- fourth=(fastest[3]==pokespeed1 && !(neworder.include?(@pkmn1)))? @pkmn1 : ((fastest[3]==pokespeed2 && !(neworder.include?(@pkmn2)))? @pkmn2 : ((fastest[3]==pokespeed3 && !(neworder.include?(@pkmn3)))? @pkmn3 : @pkmn4))
- neworder.push(fourth)
- @pokeorder=neworder
- end
- ###############################################################################
- # Determine order for next round
- ###############################################################################
- def pbOrder
- order=[]
- @stars=[]
- mosthearts=[@pkmn1total,@pkmn2total,@pkmn3total,@pkmn4total].sort.reverse
- if @MoveUp.include?(true)
- for i in 0...@MoveUp.length
- if @MoveUp[i]==true && @MoveDown[i]==false
- newpoke=(@pokeorder[i]==@pkmn1)? @pkmn1:(@pokeorder[i]==@pkmn2)? @pkmn2:(@pokeorder[i]==@pkmn3)? @pkmn3:@pkmn4
- order.push(newpoke)
- newstars=(newpoke==@pkmn1)? @pkmn1stars:(newpoke==@pkmn2)? @pkmn2stars:(newpoke==@pkmn3)? @pkmn3stars:@pkmn4stars
- @stars.push(newstars)
- end
- end
- end
- if order.length<4
- for i in 0...@pokeorder.length
- newpoke=nil
- if (mosthearts[i]==@pkmn1total && !(order.include?(@pkmn1)) && @MoveDown[pbCurrentPokeNum2(@pkmn1)]==false)
- newpoke=@pkmn1
- elsif (mosthearts[i]==@pkmn2total && !(order.include?(@pkmn2)) && @MoveDown[pbCurrentPokeNum2(@pkmn2)]==false)
- newpoke=@pkmn2
- elsif (mosthearts[i]==@pkmn3total && !(order.include?(@pkmn3)) && @MoveDown[pbCurrentPokeNum2(@pkmn3)]==false)
- newpoke=@pkmn3
- elsif (mosthearts[i]==@pkmn4total && !(order.include?(@pkmn4)) && @MoveDown[pbCurrentPokeNum2(@pkmn4)]==false)
- newpoke=@pkmn4
- end
- if newpoke !=nil
- order.push(newpoke)
- newstars=(newpoke==@pkmn1)? @pkmn1stars:(newpoke==@pkmn2)? @pkmn2stars:(newpoke==@pkmn3)? @pkmn3stars:@pkmn4stars
- @stars.push(newstars)
- end
- end
- end
- if @MoveDown.include?(true)
- for i in 0...@pokeorder.length
- if @MoveDown[i]==true && @MoveUp[i]==false
- newpoke=(@pokeorder[i]==@pkmn1)? @pkmn1:(@pokeorder[i]==@pkmn2)? @pkmn2:(@pokeorder[i]==@pkmn3)? @pkmn3:@pkmn4
- order.push(newpoke)
- newstars=(newpoke==@pkmn1)? @pkmn1stars:(newpoke==@pkmn2)? @pkmn2stars:(newpoke==@pkmn3)? @pkmn3stars:@pkmn4stars
- @stars.push(newstars)
- end
- end
- end
- if @Scramble==true #random order for Scramble
- orders=[@pkmn1,@pkmn2,@pkmn3,@pkmn4]
- @stars=[@pmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
- Kernel.srand
- order.shuffle
- Kernel.srand
- @stars.shuffle
- end
- @pokeorder.clear
- @pokeorder=order
- end
- ###############################################################################
- # Display Pokemon Graphics
- ###############################################################################
- def pbDisplayFastest #Displays the sprite of the fastest pokemon, as per FindFastest
- @sprites["pokemon1"]=PokemonSprite.new(@viewport)
- @sprites["pokemon1"].setPokemonBitmap(@pokeorder[0],true)
- @sprites["pokemon1"].mirror=true
- pokemony=Graphics.height/2-32
- pokemonyadjust=pokemony-32
- pbPositionPokemonSprite(@sprites["pokemon1"],178,112)
- end
- def pbDisplaySecondFastest
- @sprites["pokemon2"]=PokemonSprite.new(@viewport)
- @sprites["pokemon2"].setPokemonBitmap(@pokeorder[1],true)
- @sprites["pokemon2"].mirror=true
- pokemony=Graphics.height/2-32
- pokemonyadjust=pokemony-32
- pbPositionPokemonSprite(@sprites["pokemon2"],178,112)
- end
- def pbDisplayThirdFastest
- @sprites["pokemon3"]=PokemonSprite.new(@viewport)
- @sprites["pokemon3"].setPokemonBitmap(@pokeorder[2],true)
- @sprites["pokemon3"].mirror=true
- pokemony=Graphics.height/2-32
- pokemonyadjust=pokemony-32
- pbPositionPokemonSprite(@sprites["pokemon3"],178,112)
- end
- def pbDisplayFourthFastest
- @sprites["pokemon4"]=PokemonSprite.new(@viewport)
- @sprites["pokemon4"].setPokemonBitmap(@pokeorder[3],true)
- @sprites["pokemon4"].mirror=true
- pokemony=Graphics.height/2-32
- pokemonyadjust=pokemony-32
- pbPositionPokemonSprite(@sprites["pokemon4"],178,112)
- end
- #Didn't use this method
- def pbCurrentPokeNum(currentpos) #find pokemon's number (i.e. 1 for @pkmn1)
- case @pokeorder[currentpos-1]
- when @pkmn1
- return 1
- when @pkmn2
- return 2
- when @pkmn3
- return 3
- else pkmn4
- return 4
- end
- end
- def pbCurrentPokeNum2(poke) #find pokemon's number (i.e. 1 for @pkmn1)
- for i in 0..3
- if @pokeorder[i]==poke
- return i
- end
- end
- end
- def pbResetContestMoveEffects #End round reset
- @Oblivious=[false,false,false,false]
- @AvoidOnce=[0,0,0,0]
- @Scramble=false
- @MoveUp=[false,false,false,false]
- @MoveDown=[false,false,false,false]
- @UpCondition=[false,false,false,false]
- @previoushearts=0
- @crowdexcitment=true
- @goodappeal=[false,false,false,false]
- @easilystartled=[false,false,false,false]
- @nervous=[false,false,false,false]
- @jamaffected=[false,false,false,false]
- @hasattention=[false,false,false,false]
- pbNervousGraphic
- pbObliviousGraphic
- end
- ###############################################################################
- # Adjusts hearts via movefunctions. New move functions go in case statement
- ###############################################################################
- def pbFunctionsAdjustHearts
- contestmovedata=PBContestMoveData.new(@currentmove)
- @currentfunction=contestmovedata.contestfunction
- @currentjam=contestmovedata.jam
- i=@currentpos-1
- case @currentfunction
- when 1
- @AvoidOnce[i]=1
- pbObliviousGraphic
- when 2
- @Oblivious[i]=true
- pbObliviousGraphic
- when 3
- @MoveUp[i]=true
- when 4
- @UpCondition[i]=true
- when 5
- Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the other Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- if @currentpos==4
- if @Oblivious[2]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[2]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[2]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(2)
- pbJam(@currentjam,@pokeorder[2],3)
- pbDecreaseHearts(@pokeorder[2],3)
- pbStartleGraphic(2,2)
- end
- if @Oblivious[1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[1]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[1]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(1)
- pbJam(@currentjam,@pokeorder[1],2)
- pbDecreaseHearts(@pokeorder[1],2)
- pbStartleGraphic(1,1)
- end
- if @Oblivious[0]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[0]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[0]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(0)
- pbJam(@currentjam,@pokeorder[0],1)
- pbDecreaseHearts(@pokeorder[0],1)
- pbStartleGraphic(0,0)
- end
- elsif @currentpos==3
- if @Oblivious[1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[1]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[1]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(1)
- pbJam(@currentjam,@pokeorder[1],2)
- pbDecreaseHearts(@pokeorder[1],2)
- pbStartleGraphic(1,1)
- end
- if @Oblivious[0]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[0]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[0]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(0)
- pbJam(@currentjam,@pokeorder[0],1)
- pbDecreaseHearts(@pokeorder[0],1)
- pbStartleGraphic(0,0)
- end
- elsif @currentpos==2
- if @Oblivious[0]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[0]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[0]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(0)
- pbJam(@currentjam,@pokeorder[0],1)
- pbDecreaseHearts(@pokeorder[0],1)
- pbStartleGraphic(0,0)
- end
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]But it failed.."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- end
- when 6
- @currenthearts=@currentpos
- @currenthearts=(@currentpos+1) if @currenpos==4
- when 7
- for j in 0...3
- if @hasattention[j]==true && !(j==@currentpos-1)
- if @Oblivious[j]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[j]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[j]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(j-1)
- pbJam(@currentjam,@pokeorder[j],j+1)
- pbDecreaseHearts(@pokeorder[j],j+1)
- pbStartleGraphic(j-1,j-1)
- end
- end
- end
- when 8
- Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the previous Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- if @currentpos==4
- if @Oblivious[2]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[2]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[2]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(2)
- pbJam(@currentjam,@pokeorder[2],3)
- pbDecreaseHearts(@pokeorder[2],3)
- pbStartleGraphic(2,2)
- end
- elsif @currentpos==3
- if @Oblivious[1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[1]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[1]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(1)
- pbJam(@currentjam,@pokeorder[1],2)
- pbDecreaseHearts(@pokeorder[1],2)
- pbStartleGraphic(1,1)
- end
- elsif @currentpos==2
- if @Oblivious[0]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[0]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[0]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(0)
- pbJam(@currentjam,@pokeorder[0],1)
- pbDecreaseHearts(@pokeorder[0],1)
- pbStartleGraphic(0,0)
- end
- else
- end
- when 9
- if @priorhearts[@currentpos-1]>=3
- @currenthearts=(@currenthearts*2)
- else
- @currenthearts==1
- end
- when 10
- @easilystartled[i]=true
- when 11
- @MoveDown[i]=true
- when 12
- for j in 0..3
- if @priorhearts[j]>3
- if @Oblivious[j]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[j]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[j]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(j-1)
- pbJam(@currentjam,@pokeorder[j],j+1)
- pbDecreaseHearts(@pokeorder[j],j+1)
- pbStartleGraphic(j-1,j-1)
- end
- end
- end
- when 13
- Kernel.pbCustomMessage(_INTL("\\l[3]The crowd died down!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @crowdexcitment=false
- when 14
- if @currentpos==1
- Kernel.pbCustomMessage(_INTL("\\l[3]The standout {1} hustled even more!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @currenthearts=(@currenthearts*2)
- end
- when 16
- pbSetMissTurn
- Kernel.pbCustomMessage(_INTL("\\l[3]It tried to startle the other Pokemon!"),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- if @currentpos==4
- if @Oblivious[2]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[2]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[2].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[2]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(2)
- pbJam(@currentjam,@pokeorder[2],3)
- pbDecreaseHearts(@pokeorder[2],3)
- pbStartleGraphic(2,2)
- end
- if @Oblivious[1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[1]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[1]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(1)
- pbJam(@currentjam,@pokeorder[1],2)
- pbDecreaseHearts(@pokeorder[1],2)
- pbStartleGraphic(1,1)
- end
- if @Oblivious[0]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[0]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[0]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(0)
- pbJam(@currentjam,@pokeorder[0],1)
- pbDecreaseHearts(@pokeorder[0],1)
- pbStartleGraphic(0,0)
- end
- elsif @currentpos==3
- if @Oblivious[1]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[1]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[1].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[1]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(1)
- pbJam(@currentjam,@pokeorder[1],2)
- pbDecreaseHearts(@pokeorder[1],2)
- pbStartleGraphic(1,1)
- end
- if @Oblivious[0]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[0]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[0]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(0)
- pbJam(@currentjam,@pokeorder[0],1)
- pbDecreaseHearts(@pokeorder[0],1)
- pbStartleGraphic(0,0)
- end
- elsif @currentpos==2
- if @Oblivious[0]==true
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif @AvoidOnce[0]>0
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} managed to avoid seeing it",@pokeorder[0].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @AvoidOnce[0]=0
- pbObliviousGraphic
- else
- pbStartleGraphic(0)
- pbJam(@currentjam,@pokeorder[0],1)
- pbDecreaseHearts(@pokeorder[0],1)
- pbStartleGraphic(0,0)
- end
- else
- end
- when 17
- if @currentpos==1
- for j in 1..3
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @nervous[j]=true
- end
- elsif @currentpos==2
- for i in 2..3
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[j].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @nervous[j]=true
- end
- elsif @currentpos==3
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} became nervous.",@pokeorder[3].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @nervous[3]=true
- end
- pbNervousGraphic
- when 18
- pbSetNoMoreMoves
- when 19
- @currenthearts=(@applause+1)
- when 20
- @currenthearts=(rand(5)+1)
- when 21
- if @currentpos==4
- Kernel.pbCustomMessage(_INTL("\\l[3]The standout {1} hustled even more!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @currenthearts=5
- end
- when 22
- if @currentpos==0
- Kernel.pbCustomMessage(_INTL("\\l[3]But it failed."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- else
- for j in 0...@currentpos-1
- pbDecreaseStarGraphics(j,1)
- end
- end
- when 23
- @currenthearts=@currentpos
- @currenthearts=(@currentpos+1) if @currenpos==4
- when 24
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} scrambled up the order for the next turn!",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @Scramble=true
- when 25
- if @moveType==@lastmoveType
- @currenthearts=(@currenthearts*2)
- end
- when 26
- @MoveDown[i]=true
- when 27
- pbSetDoubleNext
- Kernel.pbCustomMessage(_INTL("\\l[3]{1} is getting prepared.",@pokeorder[i].name),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @currenthearts=1
- when 28
- @currenthearts=(rand(5)+1)
- when 29
- if @currentpos==1
- @currenthearts=1
- else
- if @priorhearts[@currentpos-1]<3
- @currenthearts=(@currenthearts*2)
- else
- @currenthearts=1
- end
- end
- when 30
- if @currentpos==1
- @currenthearts=1
- else
- @currenthearts=(@priorhearts[currentpos-1]/2).floor
- end
- when 31
- @applause=5
- pbCrowd(move="notnil")
- when 32
- if @currentpos==0
- Kernel.pbCustomMessage(_INTL("\\l[3]But if failed."),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- elsif
- for j in 0...@currentpos
- if @stars[j]>0
- pbDecreaseStarGraphics(j,1)
- end
- end
- end
- when 33
- @currenthearts=@applause
- when 34
- @currenthearts=@priorhearts[currentpos-1]
- when 35
- @currenthearts=@stars[@currentpos-1]
- when 36
- if @movetype==@contestType
- @currenthearts=(@currenthearts+1)
- else
- @currenthearts=@currenthearts
- end
- when 37
- @currenthearts=(@currenthearts+@priorhearts[@currentpos-1])
- when 38
- currentApplause = @applause
- currentApplause = 5 if currentApplause<0 || 5<currentApplause
- @currenthearts=6-currentApplause
- when 39
- @currenthearts=(@round+1)
- when 40
- if @currentpos>1
- if @priorhearts[@currentpos-1] >3
- @currenthearts=(@currenthearts*2)
- end
- else
- @currenthearts=1
- end
- when 41
- @currenthearts=@applause
- else
- @currenthearts=@currenthearts
- end
- end
- ###############################################################################
- # Controls Applause meter
- ###############################################################################
- def pbCrowd(move=nil)
- xPos=-172
- @sprites["Applause Bar"]=IconSprite.new(xPos,0,@viewport)
- @sprites["Applause Bar"].setBitmap("Graphics/Pictures/Contest/applause")
- applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
- @sprites["applausemeter"]=IconSprite.new((xPos+19),50,@viewport)
- @sprites["applausemeter"].setBitmap(applausefile)
- 43.times do |i|
- xPos+=4
- @sprites["applausemeter"].x=(xPos+19)
- @sprites["Applause Bar"].x=xPos
- Graphics.update
- end
- if move==nil
- if @moveType==@contestType
- @applause=(@applause+1)
- applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
- @sprites["applausemeter"].setBitmap(applausefile)
- Graphics.update
- if @moveType=="Beauty"
- Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2} went over great!",@pokeorder[@currentpos-1].name,@contestType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2}ness went over great!",@pokeorder[@currentpos-1].name,@contestType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- end
- @currenthearts=1
- pbDisplayAddingPositiveHearts
- else
- if @moveType=="Beauty"
- Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2} didn't go over very well!",@pokeorder[@currentpos-1].name,@moveType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- else
- Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2}ness didn't go over very well!",@pokeorder[@currentpos-1].name,@moveType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- end
- if @applause>0
- @applause-=1
- applausefile=sprintf("Graphics/Pictures/Contest/applause%d",@applause)
- @sprites["applausemeter"].setBitmap(applausefile)
- end
- pbJam(1,@pokeorder[@currentpos-1],@currentpos)
- pbDecreaseHearts(@pokeorder[@currentpos-1],@currentpos,"notnil")
- Graphics.update
- end
- if @crowdexcitment==true && @applause==5
- Kernel.pbCustomMessage(_INTL("\\l[3]{1}'s {2} really got the crowd going!",@pokeorder[@currentpos-1].name,@moveType),"Graphics/Pictures/Contest/choice 29",newx=nil,340)
- @currenthearts=5
- pbDisplayAddingPositiveHearts
- @applause=0
- end
- if @sprites["Applause Bar"]
- 43.times do |i|
- xPos-=4
- @sprites["Applause Bar"].x=xPos
- @sprites["applausemeter"].x=xPos+19 if @sprites["applausemeter"]
- Graphics.update
- end
- end
- pbDisposeSprite(@sprites,"Applause Bar") if @sprites["Applause Bar"]
- pbDisposeSprite(@sprites,"applausemeter") if @sprites["applausemeter"]
- Graphics.update
- end
- end
- def pbJam(jam,target,position)
- case target
- when @pkmn1
- @pkmn1jam=jam
- when @pkmn2
- @pkmn2jam=jam
- when @pkmn3
- @pkmn3jam=jam
- else
- @pkmn4jam=jam
- end
- end
- ###############################################################################
- # Miscellaneous Graphic functions
- ###############################################################################
- def pbNervousGraphic
- if @nervous[0]==true && !@sprites["nervousone"]
- @sprites["nervousone"]=IconSprite.new(374,47,@viewport)
- @sprites["nervousone"].setBitmap("Graphics/Pictures/Contest/nervous")
- end
- if @nervous[1]==true && !@sprites["nervoustwo"]
- @sprites["nervoustwo"]=IconSprite.new(374,143,@viewport)
- @sprites["nervoustwo"].setBitmap("Graphics/Pictures/Contest/nervous")
- end
- if @nervous[2]==true && !@sprites["nervousthree"]
- @sprites["nervousthree"]=IconSprite.new(374,239,@viewport)
- @sprites["nervousthree"].setBitmap("Graphics/Pictures/Contest/nervous")
- end
- if @nervous[3]==true && !@sprites["nervousfour"]
- @sprites["nervousfour"]=IconSprite.new(374,335,@viewport)
- @sprites["nervousfour"].setBitmap("Graphics/Pictures/Contest/nervous")
- end
- if @nervous[0]==false
- pbDisposeSprite(@sprites,"nervousone") if @sprites["nervousone"]
- end
- if @nervous[1]==false
- pbDisposeSprite(@sprites,"nervoustwo") if @sprites["nervoustwo"]
- end
- if @nervous[2]==false
- pbDisposeSprite(@sprites,"nervousthree") if @sprites["nervousthree"]
- end
- if @nervous[3]==false
- pbDisposeSprite(@sprites,"nervousfour") if @sprites["nervousfour"]
- end
- end
- def pbObliviousGraphic
- if (@Oblivious[0]==true || @AvoidOnce[0]>0) && !@sprites["obliviousone"]
- @sprites["obliviousone"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
- @sprites["obliviousone"].setBitmap("Graphics/Pictures/Contest/oblivious")
- end
- if (@Oblivious[1]==true || @AvoidOnce[1]>0) && !@sprites["oblivioustwo"]
- @sprites["oblivioustwo"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
- @sprites["oblivioustwo"].setBitmap("Graphics/Pictures/Contest/oblivious")
- end
- if (@Oblivious[2]==true || @AvoidOnce[2]>0) && !@sprites["obliviousthree"]
- @sprites["obliviousthree"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
- @sprites["obliviousthree"].setBitmap("Graphics/Pictures/Contest/oblivious")
- end
- if (@Oblivious[3]==true || @AvoidOnce[3]>0) && !@sprites["obliviousfour"]
- @sprites["obliviousfour"]=IconSprite.new(374,47+(96*(@currentpos-1)),@viewport)
- @sprites["obliviousfour"].setBitmap("Graphics/Pictures/Contest/oblivious")
- end
- if @Oblivious[0]==false && @AvoidOnce[0]==0
- pbDisposeSprite(@sprites,"obliviousone") if @sprites["obliviousone"]
- end
- if @Oblivious[1]==false && @AvoidOnce[1]==0
- pbDisposeSprite(@sprites,"oblivioustwo") if @sprites["oblivioustwo"]
- end
- if @Oblivious[2]==false && @AvoidOnce[2]==0
- pbDisposeSprite(@sprites,"obliviousthree") if @sprites["obliviousthree"]
- end
- if @Oblivious[3]==false && @AvoidOnce[3]==0
- pbDisposeSprite(@sprites,"obliviousfour") if @sprites["obliviousfour"]
- end
- end
- def pbStartleGraphic(position,deletepos=5)
- if position==0 && !@sprites["startleone"]
- @sprites["startleone"]=IconSprite.new(374,47,@viewport)
- @sprites["startleone"].setBitmap("Graphics/Pictures/Contest/startle")
- end
- if position==1 && !@sprites["startletwo"]
- @sprites["startletwo"]=IconSprite.new(374,143,@viewport)
- @sprites["startletwo"].setBitmap("Graphics/Pictures/Contest/startle")
- end
- if position==2 && !@sprites["startlethree"]
- @sprites["startlethree"]=IconSprite.new(374,239,@viewport)
- @sprites["startlethree"].setBitmap("Graphics/Pictures/Contest/startle")
- end
- if position==3 && !@sprites["startlefour"]
- @sprites["startlefour"]=IconSprite.new(374,335,@viewport)
- @sprites["startlefour"].setBitmap("Graphics/Pictures/Contest/startle")
- end
- if deletepos<5
- if deletepos==0
- pbDisposeSprite(@sprites,"startleone") if @sprites["startleone"]
- end
- if deletepos==1
- pbDisposeSprite(@sprites,"startletwo") if @sprites["startletwo"]
- end
- if deletepos==2
- pbDisposeSprite(@sprites,"startlethree") if @sprites["startlethree"]
- end
- if deletepos==3
- pbDisposeSprite(@sprites,"startlefour") if @sprites["startlefour"]
- end
- end
- Graphics.update
- end
- def pbDecreaseStarGraphics(position,change,decrease=true)
- case @stars[position]
- when @pkmn1stars
- for i in 0..change
- @pkmn1stars -= 1 if decrease==true && @pkmn1stars>0
- @pkmn1stars += 1 if decrease==false
- @sprites["firstpokestars"]=IconSprite.new(350,78+(94*position),@viewport) unless @sprites["firstpokestars"]
- starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn1stars) if @pkmn1stars<=6
- @sprites["firstpokestars"].setBitmap(starfile)
- sleep(1.0/7.0)
- Graphics.update
- break if @pkmn1stars==0
- end
- when @pkmn2stars
- for i in 0..change
- @pkmn2stars -= 1 if decrease==true && @pkmn2stars>0
- @pkmn2stars += 1 if decrease==false
- @sprites["secondpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["secondpokestars"]
- starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn2stars) if @pkmn2stars<=6
- @sprites["secondpokestars"].setBitmap(starfile)
- sleep(1.0/7.0)
- Graphics.update
- break if @pkmn2stars==0
- end
- when @pkmn3stars
- for i in 0..change
- @pkmn3stars -= 1 if decrease==true && @pkmn3stars>0
- @pkmn3stars += 1 if decrease==false
- @sprites["thirdpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["thirdpokestars"]
- starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn3stars) if @pkmn3stars<=6
- @sprites["thirdpokestars"].setBitmap(starfile)
- sleep(1.0/7.0)
- Graphics.update
- break if @pkmn3stars==0
- end
- when @pkmn4stars
- for i in 0..change
- @pkmn4stars -= 1 if decrease==true && @pkmn4stars>0
- @pkmn4stars += 1 if decrease==false
- @sprites["fourthpokestars"]=IconSprite.new(350,78+(96*position),@viewport) unless @sprites["fourthpokestars"]
- starfile=sprintf("Graphics/Pictures/Contest/stars%d",@pkmn4stars) if @pkmn4stars<=6
- @sprites["fourthpokestars"].setBitmap(starfile)
- sleep(1.0/7.0)
- Graphics.update
- break if @pkmn4stars==0
- end
- end
- end
- ################################################################################
- # Move Buttons
- ################################################################################
- def pbMoveButtons
- pokemon=@pkmn1
- pokename=pokemon.name
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @sprites["moves"]=IconSprite.new(0,187,@viewport)
- @sprites["moves"].setBitmap("Graphics/Pictures/Contest/moves")
- base=Color.new(64,64,64)
- shadow=Color.new(0,0,0)
- @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
- @sprites["overlay1"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
- overlay=@sprites["overlay"].bitmap
- overlay1=@sprites["overlay1"].bitmap
- pbSetSmallFont(overlay)
- textpos=[
- [_INTL("Please select a move."),12,165,0,Color.new(256,256,256),shadow]]
- imagepos=[]
- textpos1=[]
- yPos=195
- xPos=10
- selectYPos=191
- @sprites["selectbar"]=IconSprite.new(6,selectYPos,@viewport)
- @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1")
- selection=0
- selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
- for i in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(i)
- if selectedmove==name
- selectedmove=getID(PBContestMoves,i)
- end
- end
- selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
- contestmovedata=PBContestMoveData.new(selectedmove)
- selectedhearts=contestmovedata.hearts
- selectedjam=contestmovedata.jam
- jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
- @sprites["selectjam"]=IconSprite.new(400,235,@viewport)
- @sprites["selectjam"].setBitmap(jamfile)
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
- @sprites["selecthearts"]=IconSprite.new(400,200,@viewport)
- @sprites["selecthearts"].setBitmap(heartfile)
- if @pkmn1.moves[selection].id>0
- textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
- Color.new(256,256,256),Color.new(0,0,0)])
- pbDrawTextPositions(overlay1,textpos1)
- end
- drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
- for i in 0...pokemon.numMoves
- if pokemon.moves[i].id>0
- selectedmove=PBMoves.getName(@pkmn1.moves[i].id)
- for j in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(j)
- if selectedmove==name
- selectedmove=getID(PBContestMoves,j)
- end
- end
- contestmovedata=PBContestMoveData.new(selectedmove)
- moveType=contestmovedata.contestType
- imagepos.push(["Graphics/Pictures/Contest/contesttype",xPos,yPos,0,
- moveType*28,64,28])
- if @pkmn1lastmove && PBMoves.getName(pokemon.moves[i].id)==@pkmn1lastmove
- textpos.push([PBMoves.getName(pokemon.moves[i].id),xPos+68,yPos+10,0,Color.new(175,175,175),Color.new(0,0,0)])
- else
- textpos.push([PBMoves.getName(pokemon.moves[i].id),xPos+68,yPos+10,0,Color.new(256,256,256),Color.new(0,0,0)])
- end
- else
- textpos.push(["-",316,yPos,0,Color.new(256,256,256),Color.new(0,0,0)])
- end
- yPos+=44
- end
- pbDrawTextPositions(overlay,textpos)
- pbDrawImagePositions(overlay,imagepos)
- loop do
- Graphics.update
- Input.update
- self.update
- if Input.trigger?(Input::DOWN)
- if selection<pokemon.numMoves-1
- selection+=1
- else
- selection=0
- end
- selectYPos=(selection*45 + 192)
- selectYPos=(selection*45+191) if selection==0
- selectYPos=(selection*45+190) if selection==1
- @sprites["selectbar"].y=selectYPos
- @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1") if selection==0
- @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect") if selection!=0
- selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
- for i in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(i)
- if selectedmove==name
- selectedmove=getID(PBContestMoves,i)
- end
- end
- contestmovedata=PBContestMoveData.new(selectedmove)
- selectedhearts=contestmovedata.hearts
- selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
- selectedjam=contestmovedata.jam
- jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
- @sprites["selectjam"].setBitmap(jamfile)
- @sprites["selecthearts"].setBitmap(heartfile)
- overlay1.clear
- textpos1.clear
- @sprites["overlay1"].bitmap
- textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
- Color.new(256,256,256),Color.new(0,0,0)])
- drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
- pbDrawTextPositions(overlay1,textpos1)
- end
- if Input.trigger?(Input::UP)
- if selection>0
- selection-=1
- else
- selection=pokemon.numMoves-1
- end
- selectYPos=(selection*45 + 192)
- selectYPos=(selection*45+191) if selection==0
- selectYPos=(selection*45+190) if selection==1
- @sprites["selectbar"].y=selectYPos
- @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect1") if selection==0
- @sprites["selectbar"].setBitmap("Graphics/Pictures/Contest/contestselect") if selection!=0
- selectedmove=PBMoves.getName(@pkmn1.moves[selection].id)
- for i in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(i)
- if selectedmove==name
- selectedmove=getID(PBContestMoves,i)
- end
- end
- contestmovedata=PBContestMoveData.new(selectedmove)
- selectedhearts=contestmovedata.hearts
- selecteddescription=pbGetMessage(MessageTypes::ContestMoveDescriptions,selectedmove)
- selectedjam=contestmovedata.jam
- jamfile=sprintf("Graphics/Pictures/Contest/negaheart%d",selectedjam)
- @sprites["selectjam"].setBitmap(jamfile)
- heartfile=sprintf("Graphics/Pictures/Contest/heart%d",selectedhearts)
- @sprites["selecthearts"].setBitmap(heartfile)
- overlay1.clear
- textpos1.clear
- @sprites["overlay1"].bitmap
- textpos1.push([PBMoves.getName(@pkmn1.moves[selection].id),245,200,0,
- Color.new(256,256,256),Color.new(0,0,0)])
- drawTextEx(overlay1,245,250,255,2,selecteddescription,Color.new(256,256,256),Color.new(0,0,0))
- pbDrawTextPositions(overlay1,textpos1)
- end
- if Input.trigger?(Input::C)
- @moveselection=selection
- overlay.clear
- overlay1.clear
- textpos.clear
- imagepos.clear
- textpos1.clear
- pbDisposeSprite(@sprites,"selecthearts")
- pbDisposeSprite(@sprites,"moves")
- pbDisposeSprite(@sprites,"selectbar")
- pbDisposeSprite(@sprites,"selectjam")
- pbDisposeSprite(@sprites,"overlay")
- pbDisposeSprite(@sprites,"overlay1")
- Graphics.update
- break
- end
- end
- end
- def pbEndScene #Ends everything
- for i in 0..3
- CONTESTMOVE2[i]=0 #reset these global variables for next use
- CONTESTMOVE3[i]=0
- CONTESTMOVE4[i]=0
- end
- $CONTESTNAME2="" #reset these global variables for next use
- $CONTESTNAME3=""
- $CONTESTNAME4=""
- $game_map.autoplay
- pbFadeOutAndHide(@sprites) { update }
- pbDisposeSpriteHash(@heartsprites) if @heartsprites
- pbDisposeSpriteHash(@sprites)
- @viewport.dispose
- $scene = Scene_Map.new
- end
- def middleScene #processes scene after startScene
- loop do
- Graphics.update
- Input.update
- self.update
- if @contestover
- break
- end
- end
- end
- ###############################################################################
- #################### Animation Stuff Below ###################################
- ############## Don't change unless you know what you're doing #################
- ###############################################################################
- def pbFindAnimation(moveid,userIndex,hitnum)
- begin
- move2anim=load_data("Data/move2anim.dat")
- noflip=false
- if (userIndex&1)==0 # On player's side
- anim=move2anim[0][moveid]
- else # On opposing side
- anim=move2anim[1][moveid]
- noflip=true if anim
- anim=move2anim[0][moveid] if !anim
- end
- return [anim+hitnum,noflip] if anim
- if hasConst?(PBMoves,:TACKLE)
- anim=move2anim[0][getConst(PBMoves,:TACKLE)]
- return [anim,false] if anim
- end
- rescue
- return nil
- end
- return nil
- end
- def pbAnimation(moveid,user,target,hitnum=0)
- animid=pbFindAnimation(moveid,0,hitnum)
- return if !animid
- anim=animid[0]
- animations=load_data("Data/PkmnAnimations.rxdata")
- pbSaveShadows {
- if animid[1] # On opposing side and using OppMove animation
- pbAnimationCore(animations[anim],target,user)
- else # On player's side, and/or using Move animation
- pbAnimationCore(animations[anim],user,target)
- end
- }
- end
- def pbSaveShadows
- shadows=[]
- for i in 0...4
- s=@sprites["shadow#{i}"]
- shadows[i]=s ? s.visible : false
- s.visible=false if s
- end
- yield
- for i in 0...4
- s=@sprites["shadow#{i}"]
- s.visible=shadows[i] if s
- end
- end
- def pbAnimationCore(animation,user,target)
- return if !animation
- @briefmessage=false
- case @currentpos
- when 1
- usersprite=@sprites["pokemon1"]
- when 2
- usersprite=@sprites["pokemon2"]
- when 3
- usersprite=@sprites["pokemon3"]
- when 4
- usersprite=@sprites["pokemon4"]
- end
- targetsprite=(@atself==false)? @sprites["opponent"]:usersprite
- olduserx=usersprite ? usersprite.x : 0
- oldusery=usersprite ? usersprite.y : 0
- oldtargetx=targetsprite ? targetsprite.x : 0
- oldtargety=targetsprite ? targetsprite.y : 0
- #Start animation player
- animplayer=PBAnimationPlayerContest.new(animation,user,target,usersprite,targetsprite,self)
- userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
- userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
- targetwidth=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.width
- targetheight=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.height
- animplayer.setLineTransform(
- PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
- PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
- olduserx+(userwidth/2),oldusery+(userheight/2),
- oldtargetx+(targetwidth/2),oldtargety+(targetheight/2))
- animplayer.start
- while animplayer.playing?
- animplayer.update
- Graphics.update
- end
- usersprite.ox=0 if usersprite
- usersprite.oy=0 if usersprite
- usersprite.x=olduserx if usersprite
- usersprite.y=oldusery if usersprite
- targetsprite.ox=0 if targetsprite
- targetsprite.oy=0 if targetsprite
- targetsprite.x=oldtargetx if targetsprite
- targetsprite.y=oldtargety if targetsprite
- animplayer.dispose
- end
- # End of Animation Stuff
- ###############################################################################
- ###############################################################################
- # AI
- ###############################################################################
- def pbAI(pokemon,difficulty)
- movescores=[]
- nummoves=pokemon.numMoves-1
- for i in 0...nummoves
- score=100
- move=PBMoves.getName(pokemon.moves[i].id)
- currentmovename=PBMoves.getName(pokemon.moves[i].id)
- if pokemon.moves[i].id>0
- for j in 1..PBContestMoves.maxValue
- name=PBContestMoves.getName(j)
- if move==name
- move=getID(PBContestMoves,j)
- end
- end
- contestmovedata=PBContestMoveData.new(move)
- hearts=contestmovedata.hearts
- jam=contestmovedata.jam
- function=contestmovedata.contestfunction
- type=contestmovedata.contestType
- case function
- when 0 #No function
- score+=60 if hearts>3
- score+=30 if hearts<=3
- when 1,2 #gains oblivious. Increase score for earlier position
- case @currentpos
- when 1
- score+=60
- when 2
- score+=40
- when 4
- score-=20
- end
- when 3 #Move Up in order
- if @currentpos==4
- score+=30
- else
- score+=10
- end
- when 4 #Ups condition
- score+=30
- when 5 #Tries to startle previous pokemons
- case @currentpos
- when 4
- score+=70
- when 3
- score+=40
- when 1
- score-=20
- end
- when 6,23 #works better later
- case @currentpos
- when 4
- score+=70
- when 3
- score+=40
- when 1
- score-=20
- end
- when 7 #deducts from pokemon that has judges attention
- for k in 0...@currentpos
- score+=30 if @hasattention[k]==true
- end
- when 8 #startles pokemon in front
- case @currentpos
- when 4
- score+=40
- when 3
- score+=20
- when 1
- score-=20
- end
- when 9,40 #better if previous move was better
- if @priorhearts>=3
- score+=60
- else
- score-=20
- end
- when 10 #easily startled
- case @currentpos
- when 4
- score+=60
- when 3
- score+=40
- when 1
- score-=20
- end
- when 11 #move down in order
- if @currentpos==4
- score-=20
- else
- score+=20
- end
- when 12 #startles pokemon with good appeals
- case @currentpos
- when 4
- score+=20
- score+=30 if @priorhearts>3
- when 3
- score+=10
- score+=30 if @priorhearts>3
- when 1
- score-=20
- end
- when 13 #stops crowd excitement
- score -=20 if @applause>3
- score +=20 if @applause<=3
- when 14 #works best if performed first
- if @currentpos==1
- score+=60
- end
- when 15 #can be used multiple times without boring judge
- score+=20
- when 16 #jams pokemon and misses turn
- case @currentpos
- when 4
- score+=30
- when 3
- score+=20
- end
- if @round==5
- score+=60
- elsif @round==1
- score-=10
- end
- when 17 #makes all pokemon after nervous
- case @currentpos
- when 1
- score+=60
- when 2
- score+=40
- when 4
- score-=20
- end
- when 18 #no more moves
- if @round==5
- score+=90
- else
- score-=60
- end
- when 19 #depends on applause level
- score+=20 if @applause>2
- when 20 #depends on random
- score+=20
- when 21 #best if performed last
- if @currentpos==4
- score+=60
- end
- when 22,32 #removes a star
- if @currentpos==4 && @stars.max>1 && @stars.index(@stars.max)!=@currentpos-1
- score+=40
- end
- when 24 #Scramble
- if @round !=5
- score+=30
- end
- when 25 #works better if last move type is the same
- if @lastmoveType && type==@lastmoveType
- score+=40
- else
- score-=10
- end
- when 26 #appeal later next turn
- if @currentpos==4
- score-=20
- else
- score+=20
- end
- when 27 #double next turn
- if @round !=5
- score+=40
- else
- score-=60
- end
- when 28 #random amounts
- score+=20
- when 29 #better if last pokemon's wasn't
- if @priorhearts<3
- score+=60
- else
- score-=20
- end
- when 30 #half as much as previous pokemon
- score+=(@priorhearts/2.floor)*10 if @priorhearts
- when 31 #gets crowd going
- score+=40
- when 33,41 #better based on crowd excitement
- score+=(@applause*10).floor
- when 34,37 #same amount as last appearl
- score+=(@priorhearts.floor)*10 if @priorhearts
- when 35 #equals the pokemon's stars
- if @stars[@currentpos-1]>0
- score+=@stars[@currentpos-1]*10
- else
- score-=30
- end
- when 36
- if type==@contestType
- score+=40
- else
- score-=10
- end
- when 38 #better for lower applause
- case @applause
- when 1
- score+=60
- when 2
- score+=40
- when 3
- score+=20
- when 4
- score-=20
- end
- when 39 #better for later rounds
- case @round
- when 5
- score+=60
- when 3
- score+=40
- when 2
- score+=20
- when 1
- score-=20
- end
- end
- score+=60 if type==@contestType #better if it's the same type as the contest
- @currentmovename=currentmovename
- score+=60 if @round>1 && pbCheckforCombos==true #better if it will result in a combo
- score-=60 if @round>1 && function !=15 && pbCheckLast
- end
- movescores.push(score) if pokemon.moves[i].id>0
- end
- #movescores have been added up. Now find highest value, with a bit of variation
- stdev=pbStdDev(movescores)
- choice=movescores.index(movescores.max) #finds highest scoring move
- notchoice=movescores.index(movescores.min)
- return choice if stdev>=100 && rand(10)!=0 #use the highest scoring move if it's clearly better (stdev of 100 or more)
- newmovescores=movescores.clone
- newmovescores.sort
- secondlowest=movescores.index(newmovescores[1])
- r=rand(movescores.length)
- movescores[notchoice]=nil if difficulty>25
- movescores[secondlowest]=nil if difficulty>75
- if difficulty>25 #lowest difficulty
- return r if movescores[r]!=nil && rand(10)>4
- elsif difficulty>50
- return r if movescores[r]!=nil && rand(10)>2
- elsif difficulty>75
- 2.times do
- return r if movescores[r]!=nil && rand(10)>2
- end
- else
- return r
- end
- return r
- end
- def pbStdDev(scores) #from PokeBattle_AI
- n=0
- sum=0
- scores.each{|s| sum+=s; n+=1 }
- return 0 if n==0
- mean=sum.to_f/n.to_f
- varianceTimesN=0
- for i in 0...scores.length
- if scores[i]>0
- deviation=scores[i].to_f-mean
- varianceTimesN+=deviation*deviation
- end
- end
- # Using population standard deviation
- # [(n-1) makes it a sample std dev, would be 0 with only 1 sample]
- return Math.sqrt(varianceTimesN/n)
- end
- # End of AI
- ###############################################################################
- ###############################################################################
- # Preliminary Results. No graphics used
- ###############################################################################
- def pbPreliminaryScene
- @prelim1=0
- @prelim2=0
- @prelim3=0
- @prelim4=0
- #points for players pokemon below
- case @contestType
- when "Cool"
- @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:REDSCARF)
- @prelim1+=($Trainer.party[$game_variables[36]].cool/8).floor
- when "Beauty"
- @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:BLUESCARF)
- @prelim1+=($Trainer.party[$game_variables[36]].beauty/8).floor
- when "Smart"
- @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:GREENSCARF)
- @prelim1+=($Trainer.party[$game_variables[36]].smart/8).floor
- when "Tough"
- @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:YELLOWSCARF)
- @prelim1+=($Trainer.party[$game_variables[36]].tough/8).floor
- when "Cute"
- @prelim1+=20 if isConst?($Trainer.party[$game_variables[36]].item,PBItems,:PINKSCARF)
- @prelim1+=($Trainer.party[$game_variables[36]].cute/8).floor
- end
- @prelim1+=25 if $Trainer.party[$game_variables[36]].isShiny? #extra points if it's shiny
- #points for other pokemon below
- #points for coolness, beauty, etc. Pokemon are created with 0, so they won't have any, given by difficulty
- @prelim2+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
- @prelim3+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
- @prelim4+=(@difficulty==100)?31:(@difficulty>=75)?24:(@difficulty>=50)?19:(@difficulty>=25)?12:7
- #gives points for "scarves". Pokemon won't actually have any. Less likely to
- @prelim2+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
- @prelim3+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
- @prelim4+=20 if (@difficulty>=75 || (@difficulty>=50 && rand(2)==0))
- #points for shiny
- @prelim2+=25 if @pkmn2.isShiny?
- @prelim3+=25 if @pkmn3.isShiny?
- @prelim4+=25 if @pkmn4.isShiny?
- #add some randomness for opponents
- @prelim2+=rand(10)
- @prelim2-=rand(10)
- @prelim3+=rand(10)
- @prelim3-=rand(10)
- @prelim4+=rand(10)
- @prelim4-=rand(10)
- end
- ###############################################################################
- # Results Scene
- ###############################################################################
- def pbResultsScene
- @sprites["results"]=IconSprite.new(0,0,@viewport2)
- @sprites["results"].setBitmap("Graphics/Pictures/Contest/resultsbg")
- #draw poke icons
- @pkmn1sprite=PokemonIconSprite.new(@pkmn1,@viewport2)
- @pkmn2sprite=PokemonIconSprite.new(@pkmn2,@viewport2)
- @pkmn3sprite=PokemonIconSprite.new(@pkmn3,@viewport2)
- @pkmn4sprite=PokemonIconSprite.new(@pkmn4,@viewport2)
- #positions poke icons
- @pkmn1sprite.x=86
- @pkmn2sprite.x=86
- @pkmn3sprite.x=86
- @pkmn4sprite.x=86
- @pkmn1sprite.y=93
- @pkmn2sprite.y=@pkmn1sprite.y+50
- @pkmn3sprite.y=@pkmn2sprite.y+50
- @pkmn4sprite.y=@pkmn3sprite.y+50
- @sprites["textbitmap"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2) #bitmap to draw text on, instead of Kernel.pbMessage
- @sprites["textbitmap"].z=@viewport2.z
- #Color for rectangles, determined by contest type
- rectcolor=(@contestType=="Cool")?Color.new(178,34,34):(@contestType=="Beauty")?Color.new(0,0,255):(@contestType=="Smart")?Color.new(0,100,0):(@contestType=="Tough")?Color.new(255,215,0):Color.new(255,0,255)
- #array of the scores to use
- @results=[@prelim1*1.5.floor,@prelim2*1.5.floor,@prelim3*1.5.floor,@prelim4*1.5.floor]
- @newstars=[@pkmn1stars,@pkmn2stars,@pkmn3stars,@pkmn4stars]
- #Draw rectangles, using the prelims as the initial
- textpos=[]
- textpos.push([_INTL("Preliminary Results"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- @sprites["overlay2"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2)
- @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
- Graphics.update
- sleep(1)
- #Draw first round
- #this could probably be reduced to one loop, but it'll do more calculations in the long run
- textpos.clear
- @sprites["textbitmap"].bitmap.clear
- textpos.push([_INTL("First Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- 3.times do
- for i in 0..3
- @results[i]+=@roundonetotals[i]*1.5/3
- end
- @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
- Graphics.update
- sleep(1)
- end
- #Draw second round
- textpos.clear
- @sprites["textbitmap"].bitmap.clear
- textpos.push([_INTL("Second Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- 3.times do
- for i in 0..3
- @results[i]+=@roundtwototals[i]*1.5/3
- end
- @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
- Graphics.update
- sleep(1)
- end
- #Draw third round
- textpos.clear
- @sprites["textbitmap"].bitmap.clear
- textpos.push([_INTL("Third Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- 3.times do
- for i in 0..3
- @results[i]+=@roundthreetotals[i]*1.5/3
- end
- @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
- Graphics.update
- sleep(1)
- end
- #Draw fourth round
- textpos.clear
- @sprites["textbitmap"].bitmap.clear
- textpos.push([_INTL("Fourth Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- 3.times do
- for i in 0..3
- @results[i]+=@roundfourtotals[i]*1.5/3
- end
- @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
- Graphics.update
- sleep(1)
- end
- #Draw fifth round
- textpos.clear
- @sprites["textbitmap"].bitmap.clear
- textpos.push([_INTL("Fifth Round"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- 3.times do
- for i in 0..3
- @results[i]+=@roundfivetotals[i]*1.5/3
- end
- @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
- Graphics.update
- sleep(1)
- end
- #draw Stars
- textpos.clear
- @sprites["textbitmap"].bitmap.clear
- textpos.push([_INTL("Stars Earned"),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- 3.times do
- for i in 0..3
- @results[i]+=@newstars[i]*10/3
- end
- @sprites["overlay2"].bitmap.fill_rect(167,128,@results[0],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,178,@results[1],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,228,@results[2],20,rectcolor)
- @sprites["overlay2"].bitmap.fill_rect(167,278,@results[3],20,rectcolor)
- Graphics.update
- sleep(1)
- end
- winner=[@pkmn1total*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
- 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
- textpos.clear
- @sprites["textbitmap"].bitmap.clear
- textpos.push([(_INTL("{1} is the winner!",win.name)),Graphics.width/3,309,0,rectcolor,Color.new(136,168,208)])
- pbDrawTextPositions(@sprites["textbitmap"].bitmap,textpos)
- if win==@pkmn1
- @@won=true
- $Trainer.party[$game_variables[36]].giveRibbon(@ribbonnum) if !($Trainer.party[$game_variables[36]].hasRibbon?(@ribbonnum))
- end
- Graphics.update
- sleep(1)
- @pkmn1sprite.dispose
- @pkmn2sprite.dispose
- @pkmn3sprite.dispose
- @pkmn4sprite.dispose
- @sprites["overlay2"].bitmap.clear
- end
- ################################################################################
- def won
- return @@won==true
- end
- end
- class PokeContest
- def initialize(scene)
- @scene=scene
- end
- def pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
- @scene.pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
- @scene.middleScene
- @scene.pbEndScene
- return @scene.won
- end
- end
- def pbContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
- scene=PokeContestScene.new
- screen=PokeContest.new(scene)
- return screen.pbStartContest(difficulty,opponent1,opponent1level,opponent2,opponent2level,opponent3,opponent3level,ribbonnum)
- end
- ################################################################################
- # Define Contest Combos here
- ################################################################################
- #define all combos here. first entry in array starts the combo, the rest are the options to follow it
- #name them by their name used in the game, not the internal name
- combo1=["Belly Drum","Rest"]
- combo2=["Calm Mind","Confusion","Dream Eater","Future Sight","Light Screen","Luster Purge","Meditate","Mist Ball","Psybeam","Psychic","Psycho Boost","Psywave","Reflect"]
- combo3=["Charge","Shock Wave","Spark","Thunder","Thunderbolt","Thunder Punch","Thunder Shock","Thunder Wave","Volt Tackle","Zap Cannon"]
- combo4=["Charm","Flatter","Growl","Rest","Tail Whip"]
- combo5=["Confusion","Future Sight","Kinesis","Psychic","Teleport"]
- combo6=["Curse","Destiny Bond","Grudge","Mean Look","Spite"]
- combo7=["Defense Curl","Rollout","Tackle"]
- combo8=["Dive","Surf"]
- combo9=["Double Team","Agility","Quick Attack","Teleport"]
- combo10=["Dragon Breath","Dragon Claw","Dragon Dance","Dragon Rage"]
- combo11=["Dragon Dance","Dragon Breath","Dragon Claw","Dragon Rage"]
- combo12=["Dragon Rage","Dragon Breath","Dragon Claw","Dragon Dance"]
- combo13=["Earthquake","Eruption","Fissure"]
- combo14=["Endure","Flail","Reversal"]
- combo15=["Fake Out","Arm Thrust","Feint Attack","Knock Off","Seismic Toss","Vital Throw"]
- combo16=["Fire Punch","Ice Punch","Thunder Punch"]
- combo17=["Focus Energy","Arm Thrust","Brick Break","Cross Chop","Double Edge","DynamicPunch","Focus Punch","Headbutt","Karate Chop","Sky Uppercut","Take Down"]
- combo18=["Growth","Absorb","Bullet Seed","Frenzy Plant","Giga Drain","Leech Seed","Magical Leaf","Mega Drain","Petal Dance","Razor Leaf","SolarBeam","Vine Whip"]
- combo19=["Hail","Aurora Beam","Blizzard","Haze","Ice Ball","Ice Beam","Icicle Spear","Icy Wind","Powder Snow","Sheer Cold","Weather Ball"]
- combo20=["Harden","Double Edge","Protect","Rollout","Tackle","Take Down"]
- combo21=["Horn Attack","Horn Drill","Fury Attack"]
- combo22=["Hypnosis","Dream Eater"]
- combo23=["Ice Punch","Fire Punch","Thunder Punch"]
- combo24=["Kinesis","Confusion","Future Sight","Psychic","Teleport"]
- combo25=["Leer","Bite","Feint Attack","Glare","Horn Attack","Scary Face","Scratch","Stomp","Tackle"]
- combo26=["Lock-On","Superpower","Thunder","Tri Attack","Zap Cannon"]
- combo27=["Mean Look","Destiny Bond","Perish Song"]
- combo28=["Metal Sound","Metal Claw"]
- combo29=["Mind Reader","DynamicPunch","Hi Jump Kick","Sheer Cold","Submission","Superpower"]
- combo30=["Mud Sport","Mud-Slap","Water Gun","Water Sport"]
- combo31=["Peck","Drill Peck","Fury Attack"]
- combo32=["Pound","Double Slap","Feint Attack","Slam"]
- combo33=["Powder Snow","Blizzard"]
- combo34=["Psychic","Confusion","Teleport","Future Sight","Kinesis"]
- combo35=["Rage","Leer","Scary Face","Thrash"]
- combo36=["Rain Dance","Bubble","Bubblebeam","Clamp","Crabhammer","Dive","Hydro Cannon","Hydro Pump","Muddy Water","Octazooka","Surf","Thunder","Water Gun","Water Pulse","Water Sport","Water Spout","Waterfall","Weather Ball","Whirlpool"]
- combo37=["Rest","Sleep Talk","Snore"]
- combo38=["Rock Throw","Rock Slide","Rock Tomb"]
- combo39=["Sand-Attack","Mud-Slap"]
- combo40=["Sandstorm","Mud Shot","Mud-Slap","Mud Sport","Sand Tomb","Sand-Attack","Weather Ball"]
- combo41=["Scary Face","Bite","Crunch","Leer"]
- combo42=["Scratch","Fury Swipes","Slash"]
- combo43=["Sing","Perish Song","Refresh"]
- combo44=["Sludge","Sludge Bomb"]
- combo45=["Sludge Bomb","Sludge"]
- combo46=["Smog","Smokescreen"]
- combo47=["Stockpile","Spit Up","Swallow"]
- combo48=["Sunny Day","Blast Burn","Blaze Kick","Ember","Eruption","Fire Blast","Fire Punch","Fire Spin","Flame Wheel","Flamethrower","Heat Wave","Moonlight","Morning Sun","Overheat","Sacred Fire","SolarBeam","Synthesis","Weather Ball","Will-o-Wisp"]
- combo49=["Surf","Dive"]
- combo50=["Sweet Scene","Poison Powder","Sleep Powder","Stun Spore"]
- combo51=["Swords Dance","Crabhammer","Crush Claw","Cut","False Swipe","Fury Cutter","Slash"]
- combo52=["Taunt","Counter","Detect","Mirror Coat"]
- combo53=["Thunder Punch","Fire Punch","Ice Punch"]
- combo54=["Vice Grip","Bind","Guillotine"]
- combo55=["Water Sport","Mud Sport","Refresh","Water Gun"]
- combo56=["Yawn","Rest","Slack Off"]
- #add more combos here
- #then add them to this array below
- CONTESTCOMBOS=[combo1,combo2,combo3,combo4,combo5,combo6,combo7,combo8,combo9,combo10,combo11,combo12,combo13,combo14,combo15,combo16,combo17,combo18,combo19,combo20,combo21,combo22,combo23,combo24,combo25,combo26,combo27,combo28,combo29,combo30,
- combo31,combo32,combo33,combo34,combo35,combo36,combo37,combo38,combo39,combo40,combo41,combo42,combo43,combo44,combo45,combo46,combo47,combo48,combo49,combo50,combo51,combo52,combo53,combo54,combo55,combo56]
- ################################################################################
- # blank array to store moves to teach contest pokemon
- ################################################################################
- CONTESTMOVE2=[0,0,0,0]
- CONTESTMOVE3=[0,0,0,0]
- CONTESTMOVE4=[0,0,0,0]
- def pbAddContestMove(poke,move1=0,move2=0,move3=0,move4=0)
- poketochange=[0,0,0,0]
- poketochange[0]=move1
- poketochange[1]=move2
- poketochange[2]=move3
- poketochange[3]=move4
- case poke
- when 2
- for i in 0..3
- CONTESTMOVE2[i]=poketochange[i]
- end
- when 3
- for i in 0..3
- CONTESTMOVE3[i]=poketochange[i]
- end
- when 4
- for i in 0..3
- CONTESTMOVE4[i]=poketochange[i]
- end
- end
- end
- ################################################################################
- # nicknaming contest pokemon
- ################################################################################
- $CONTESTNAME2=""
- $CONTESTNAME3=""
- $CONTESTNAME4=""
- def pbChangeContestName(poke,name="")
- if name !="" && name.length<16
- case poke
- when 2
- $CONTESTNAME2=name
- when 3
- $CONTESTNAME3=name
- when 4
- $CONTESTNAME4=name
- end
- end
- end
- ################################################################################
- # Animation player for contest
- ################################################################################
- class PBAnimationPlayerContest
- attr_accessor :looping
- MAXSPRITES=30
- def initialize(animation,user,target,usersprite,targetsprite,scene=nil,ineditor=false)
- @animation=animation
- @user=user
- @usersprite=usersprite
- @targetsprite=targetsprite
- @userbitmap=(@usersprite && @usersprite.bitmap) ? @usersprite.bitmap : nil # not to be disposed
- @targetbitmap=(@targetsprite && @targetsprite.bitmap) ? @targetsprite.bitmap : nil # not to be disposed
- @scene=scene
- @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z=99999
- @ineditor=ineditor
- @looping=false
- @animbitmap=nil # Animation sheet graphic
- @frame=-1
- @srcLine=nil
- @dstLine=nil
- @userOrig=getSpriteCenter(@usersprite)
- @targetOrig=getSpriteCenter(@targetsprite)
- @animsprites=[]
- @animsprites[0]=@usersprite
- @animsprites[1]=@targetsprite
- for i in 2...MAXSPRITES
- @animsprites[i]=Sprite.new(@viewport)
- @animsprites[i].bitmap=nil
- @animsprites[i].visible=false
- end
- @bgColor=ColoredPlane.new(Color.new(0,0,0),@viewport)
- @bgColor.borderX=64 if ineditor
- @bgColor.borderY=64 if ineditor
- @bgColor.z=2
- @bgColor.opacity=0
- @bgColor.refresh
- @bgGraphic=AnimatedPlane.new(@viewport)
- @bgGraphic.setBitmap(nil)
- @bgGraphic.borderX=64 if ineditor
- @bgGraphic.borderY=64 if ineditor
- @bgGraphic.z=2
- @bgGraphic.opacity=0
- @bgGraphic.refresh
- @oldbg=[]
- @foColor=ColoredPlane.new(Color.new(0,0,0),@viewport)
- @foColor.borderX=64 if ineditor
- @foColor.borderY=64 if ineditor
- @foColor.z=38
- @foColor.opacity=0
- @foColor.refresh
- @foGraphic=AnimatedPlane.new(@viewport)
- @foGraphic.setBitmap(nil)
- @foGraphic.borderX=64 if ineditor
- @foGraphic.borderY=64 if ineditor
- @foGraphic.z=38
- @foGraphic.opacity=0
- @foGraphic.refresh
- @oldfo=[]
- end
- def dispose
- @animbitmap.dispose if @animbitmap
- for i in 2...MAXSPRITES
- @animsprites[i].dispose if @animsprites[i]
- end
- @bgGraphic.dispose
- @bgColor.dispose
- @foGraphic.dispose
- @foColor.dispose
- end
- def start
- @frame=0
- end
- def playing?
- return @frame>=0
- end
- def setLineTransform(x1,y1,x2,y2,x3,y3,x4,y4)
- @srcLine=[x1,y1,x2,y2]
- @dstLine=[x3,y3,x4,y4]
- end
- def update
- return if @frame<0
- if (@frame>>1) >= @animation.length
- @frame=(@looping) ? 0 : -1
- if @frame<0
- @animbitmap.dispose if @animbitmap
- @animbitmap=nil
- return
- end
- end
- if !@animbitmap || @animbitmap.disposed?
- @animbitmap=AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic,
- @animation.hue).deanimate
- for i in 0...MAXSPRITES
- @animsprites[i].bitmap=@animbitmap if @animsprites[i]
- end
- end
- @bgGraphic.update
- @bgColor.update
- @foGraphic.update
- @foColor.update
- if (@frame&1)==0
- thisframe=@animation[@frame>>1]
- # Make all cel sprites invisible
- for i in 0...MAXSPRITES
- @animsprites[i].visible=false if @animsprites[i]
- end
- # Set each cel sprite acoordingly
- for i in 0...thisframe.length
- cel=thisframe[i]
- next if !cel
- sprite=@animsprites[i]
- next if !sprite
- # Set cel sprite's graphic
- if cel[AnimFrame::PATTERN]==-1
- sprite.bitmap=@userbitmap
- elsif cel[AnimFrame::PATTERN]==-2
- sprite.bitmap=@targetbitmap
- else
- sprite.bitmap=@animbitmap
- end
- cel[AnimFrame::MIRROR]=1
- # Apply settings to the cel sprite
- pbSpriteSetAnimFrame(sprite,cel,@usersprite,@targetsprite)
- case cel[AnimFrame::FOCUS]
- when 1 # Focused on target
- sprite.x=cel[AnimFrame::X]+@targetOrig[0]-PokeBattle_SceneConstants::FOCUSTARGET_X
- sprite.y=cel[AnimFrame::Y]+@targetOrig[1]-PokeBattle_SceneConstants::FOCUSTARGET_Y
- when 2 # Focused on user
- sprite.x=cel[AnimFrame::X]+@userOrig[0]-PokeBattle_SceneConstants::FOCUSUSER_X
- sprite.y=cel[AnimFrame::Y]+@userOrig[1]-PokeBattle_SceneConstants::FOCUSUSER_Y
- when 3 # Focused on user and target
- if @srcLine && @dstLine
- point=transformPoint(
- @srcLine[0],@srcLine[1],@srcLine[2],@srcLine[3],
- @dstLine[0],@dstLine[1],@dstLine[2],@dstLine[3],
- sprite.x,sprite.y)
- sprite.x=point[0]
- sprite.y=point[1]
- end
- end
- sprite.x+=64 if @ineditor
- sprite.y+=64 if @ineditor
- end
- # Play timings
- @animation.playTiming(@frame>>1,@bgGraphic,@bgColor,@foGraphic,@foColor,@oldbg,@oldfo,@user)
- end
- @frame+=1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement