Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #============================================================
- #Rotation_Battle script by leilou
- #
- #This script is ment to make rotation battles possible in Pokémon Essentials
- #
- #Pokémon Essentials is created by Poccil, based on Flameguru's
- #Pokémon Starter Kit and managed and updated by Maruno
- #
- #I don't claim this script to be perfect.
- #Please report bugs at the resources thread on Relic Castle.
- #=============================================================
- #The Scenes section contains all the changed scenes and graphic related stuff
- #=============================================================
- #constants that may or may not be already be defined depending on which
- #scripts you use ... ignore the already defined ones
- BATTLERZOOM = 1 unless defined? BATTLERZOOM #scale pokemon
- STARTZOOM = 0.125 unless defined? STARTZOOM #this is to determine how big your
- #pkmn are right after coming out of
- #the pokeball at the beginning of a
- #battle
- SPRITESTEPS = 10 unless defined? SPRITESTEPS#how many frames a pkmn needs to
- #appear at the start of a battle
- #some more constants for rotation battle
- module PokeBattle_SceneConstants
- FOEBASE_ROT_XSHIFT = 0
- FOEBASE_ROT_YSHIFT = -70
- FOESHADOW_ROT_R_XSHIFT = 70
- FOESHADOW_ROT_L_XSHIFT = -70
- FOESHADOW_ROT_RL_YSHIFT = -100
- FOEBATTLER_ROT_R_XSHIFT = 70
- FOEBATTLER_ROT_L_XSHIFT = -70
- FOEBATTLER_ROT_RL_YSHIFT = -100
- end
- #extension of class PokeBattle_Scene
- class RotationBattle_Scene < PokeBattle_Scene
- def pbFrameUpdate(cw=nil)
- super
- @sprites["battleboxL"].update if @sprites["battleboxL"]
- @sprites["battleboxM"].update if @sprites["battleboxM"]
- @sprites["battleboxR"].update if @sprites["battleboxR"]
- end
- def pbRefresh
- super
- @sprites["battleboxL"].refresh if @sprites["battleboxL"]
- @sprites["battleboxM"].refresh if @sprites["battleboxM"]
- @sprites["battleboxR"].refresh if @sprites["battleboxR"]
- end
- def enemyRotateRight(showmessage = true)
- length = 14
- right_x = PokeBattle_SceneConstants::FOEBATTLER_X + PokeBattle_SceneConstants::FOEBATTLER_ROT_R_XSHIFT
- right_x -= @sprites["pokemon1"].width*0.5/2
- right_y = adjustBattleSpriteY(@sprites["pokemon1"],@battle.pokeTrainer[2].pokemon.species,1)/2
- right_y += PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBATTLER_ROT_RL_YSHIFT
- #right_y -= @sprites["pokemonL"].height*0.5
- left_x = PokeBattle_SceneConstants::FOEBATTLER_X + PokeBattle_SceneConstants::FOEBATTLER_ROT_L_XSHIFT
- left_x -= @sprites["pokemonR"].width*0.5/2
- left_y = adjustBattleSpriteY(@sprites["pokemonR"],@battle.pokeTrainer[1].pokemon.species,1)/2
- left_y += PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBATTLER_ROT_RL_YSHIFT
- #left_y -= @sprites["pokemon1"].height*0.5
- middle_x = PokeBattle_SceneConstants::FOEBATTLER_X
- middle_x -= @sprites["pokemonL"].width/2
- middle_y = adjustBattleSpriteY(@sprites["pokemonL"],@battle.pokeTrainer[0].pokemon.species,1)
- middle_y += PokeBattle_SceneConstants::FOEBATTLER_Y
- middle_x_step = (right_x - @sprites["pokemon1"].x)/length
- middle_y_step = (right_y - @sprites["pokemon1"].y)/length
- middle_zoom_step = (0.5 - @sprites["pokemon1"].zoom_x)/length
- middle_shadow_step_x = (@right_shadow_x - @sprites["shadow1"].x)/length
- middle_shadow_step_y = (@right_shadow_y - @sprites["shadow1"].y)/length + 1
- right_x_step = (left_x - @sprites["pokemonR"].x)/length
- right_y_step = (left_y - @sprites["pokemonR"].y)/length
- right_shadow_step_x = (@left_shadow_x - @sprites["shadowR"].x)/length
- right_shadow_step_y = (@left_shadow_y - @sprites["shadowR"].y)/length
- left_x_step = (middle_x - @sprites["pokemonL"].x)/length
- left_y_step = (middle_y - @sprites["pokemonL"].y)/length
- left_zoom_step = (1 - @sprites["pokemonL"].zoom_x)/length
- left_shadow_step_x = (@middle_shadow_x - @sprites["shadowL"].x)/length
- left_shadow_step_y = (@middle_shadow_y - @sprites["shadowL"].y)/length
- length.times do
- @sprites["pokemon1"].x += middle_x_step
- @sprites["pokemon1"].y += middle_y_step
- @sprites["pokemon1"].zoom_x += middle_zoom_step
- @sprites["pokemon1"].zoom_y += middle_zoom_step
- @sprites["shadow1"].x += middle_shadow_step_x
- @sprites["shadow1"].y += middle_shadow_step_y
- @sprites["pokemonR"].x += right_x_step
- @sprites["pokemonR"].y += right_y_step
- @sprites["shadowR"].x += right_shadow_step_x
- @sprites["shadowR"].y += right_shadow_step_y
- @sprites["pokemonL"].x += left_x_step
- @sprites["pokemonL"].y += left_y_step
- @sprites["pokemonL"].zoom_x += left_zoom_step
- @sprites["pokemonL"].zoom_y += left_zoom_step
- @sprites["shadowL"].x += left_shadow_step_x
- @sprites["shadowL"].y += left_shadow_step_y
- pbWait(1)
- end
- #change positions
- @sprites["pokemon1"].x = right_x
- @sprites["pokemon1"].y = right_y
- @sprites["pokemon1"].zoom_x = 0.5
- @sprites["pokemon1"].zoom_y = 0.5
- @sprites["shadow1"].x = @right_shadow_x
- @sprites["shadow1"].y = @right_shadow_y
- @sprites["pokemonR"].x = left_x
- @sprites["pokemonR"].y = left_y
- @sprites["pokemonR"].zoom_x = 0.5
- @sprites["pokemonR"].zoom_y = 0.5
- @sprites["shadowR"].x = @left_shadow_x
- @sprites["shadowR"].y = @left_shadow_y
- @sprites["pokemonL"].x = middle_x
- @sprites["pokemonL"].y = middle_y
- @sprites["pokemonL"].zoom_x = 1
- @sprites["pokemonL"].zoom_y = 1
- @sprites["shadowL"].x = @middle_shadow_x
- @sprites["shadowL"].y = @middle_shadow_y
- #assign the right names to the right sprites
- tempSprite = @sprites["pokemon1"]
- @sprites["pokemon1"] = @sprites["pokemonL"]
- @sprites["pokemonL"] = @sprites["pokemonR"]
- @sprites["pokemonR"] = tempSprite
- tempSprite = @sprites["shadow1"]
- @sprites["shadow1"] = @sprites["shadowL"]
- @sprites["shadowL"] = @sprites["shadowR"]
- @sprites["shadowR"] = tempSprite
- Graphics.update #to make it look smooth
- @sprites["battleboxM"].place=2
- @sprites["battleboxL"].place=1
- @sprites["battleboxR"].place=0
- tempBox = @sprites["battleboxM"]
- @sprites["battleboxM"] = @sprites["battleboxL"]
- @sprites["battleboxL"] = @sprites["battleboxR"]
- @sprites["battleboxR"] = tempBox
- #@sprites["battlebox1"] = @sprites["battleboxM"]
- @sprites["battleboxM"].refresh
- @sprites["battleboxR"].refresh
- @sprites["battleboxL"].refresh
- if showmessage
- trainerName = @battle.pbGetOwner(1).name
- pbDisplayMessage("#{trainerName}'s Pokémon rotated to the right!",true)
- @battle.pbDisplayBrief("")
- end
- end
- def enemyRotateLeft(showmessage = true)
- length = 14
- right_x = PokeBattle_SceneConstants::FOEBATTLER_X + PokeBattle_SceneConstants::FOEBATTLER_ROT_R_XSHIFT
- right_x -= @sprites["pokemonL"].width*0.5/2
- right_y = adjustBattleSpriteY(@sprites["pokemonL"],@battle.pokeTrainer[2].pokemon.species,1)/2
- right_y += PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBATTLER_ROT_RL_YSHIFT
- #right_y -= @sprites["pokemonL"].height*0.5
- left_x = PokeBattle_SceneConstants::FOEBATTLER_X + PokeBattle_SceneConstants::FOEBATTLER_ROT_L_XSHIFT
- left_x -= @sprites["pokemon1"].width*0.5/2
- left_y = adjustBattleSpriteY(@sprites["pokemon1"],@battle.pokeTrainer[1].pokemon.species,1)/2
- left_y += PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBATTLER_ROT_RL_YSHIFT
- #left_y -= @sprites["pokemon1"].height*0.5
- middle_x = PokeBattle_SceneConstants::FOEBATTLER_X
- middle_x -= @sprites["pokemonR"].width/2
- middle_y = adjustBattleSpriteY(@sprites["pokemonR"],@battle.pokeTrainer[0].pokemon.species,1)
- middle_y += PokeBattle_SceneConstants::FOEBATTLER_Y
- middle_x_step = (left_x - @sprites["pokemon1"].x)/length
- middle_y_step = (left_y - @sprites["pokemon1"].y)/length
- middle_zoom_step = (0.5 - @sprites["pokemon1"].zoom_x)/length
- middle_shadow_step_x = (@left_shadow_x - @sprites["shadow1"].x)/length
- middle_shadow_step_y = (@left_shadow_y - @sprites["shadow1"].y)/length + 1
- right_x_step = (middle_x - @sprites["pokemonR"].x)/length
- right_y_step = (middle_y - @sprites["pokemonR"].y)/length
- right_zoom_step = (1 - @sprites["pokemonR"].zoom_x)/length
- right_shadow_step_x = (@middle_shadow_x - @sprites["shadowR"].x)/length
- right_shadow_step_y = (@middle_shadow_y - @sprites["shadowR"].y)/length
- left_x_step = (right_x - @sprites["pokemonL"].x)/length
- left_y_step = (right_y - @sprites["pokemonL"].y)/length
- left_shadow_step_x = (@right_shadow_x - @sprites["shadowL"].x)/length
- left_shadow_step_y = (@right_shadow_y - @sprites["shadowL"].y)/length
- length.times do
- @sprites["pokemon1"].x += middle_x_step
- @sprites["pokemon1"].y += middle_y_step
- @sprites["pokemon1"].zoom_x += middle_zoom_step
- @sprites["pokemon1"].zoom_y += middle_zoom_step
- @sprites["shadow1"].x += middle_shadow_step_x
- @sprites["shadow1"].y += middle_shadow_step_y
- @sprites["pokemonR"].x += right_x_step
- @sprites["pokemonR"].y += right_y_step
- @sprites["pokemonR"].zoom_x += right_zoom_step
- @sprites["pokemonR"].zoom_y += right_zoom_step
- @sprites["shadowR"].x += right_shadow_step_x
- @sprites["shadowR"].y += right_shadow_step_y
- @sprites["pokemonL"].x += left_x_step
- @sprites["pokemonL"].y += left_y_step
- @sprites["shadowL"].x += left_shadow_step_x
- @sprites["shadowL"].y += left_shadow_step_y
- pbWait(1)
- end
- #change positions
- @sprites["pokemon1"].x = left_x
- @sprites["pokemon1"].y = left_y
- @sprites["pokemon1"].zoom_x = 0.5
- @sprites["pokemon1"].zoom_y = 0.5
- @sprites["shadow1"].x = @left_shadow_x
- @sprites["shadow1"].y = @left_shadow_y
- @sprites["pokemonL"].x = right_x
- @sprites["pokemonL"].y = right_y
- @sprites["pokemonL"].zoom_x = 0.5
- @sprites["pokemonL"].zoom_y = 0.5
- @sprites["shadowL"].x = @right_shadow_x
- @sprites["shadowL"].y = @right_shadow_y
- @sprites["pokemonR"].x = middle_x
- @sprites["pokemonR"].y = middle_y
- @sprites["pokemonR"].zoom_x = 1
- @sprites["pokemonR"].zoom_y = 1
- @sprites["shadowR"].x = @middle_shadow_x
- @sprites["shadowR"].y = @middle_shadow_y
- #assign the right names to the right sprites
- tempSprite = @sprites["pokemon1"]
- @sprites["pokemon1"] = @sprites["pokemonR"]
- @sprites["pokemonR"] = @sprites["pokemonL"]
- @sprites["pokemonL"] = tempSprite
- tempSprite = @sprites["shadow1"]
- @sprites["shadow1"] = @sprites["shadowR"]
- @sprites["shadowR"] = @sprites["shadowL"]
- @sprites["shadowL"] = tempSprite
- Graphics.update #to make it look smooth
- @sprites["battleboxM"].place=0
- @sprites["battleboxL"].place=2
- @sprites["battleboxR"].place=1
- tempBox = @sprites["battleboxM"]
- @sprites["battleboxM"] = @sprites["battleboxR"]
- @sprites["battleboxR"] = @sprites["battleboxL"]
- @sprites["battleboxL"] = tempBox
- #@sprites["battlebox1"] = @sprites["battleboxM"]
- @sprites["battleboxM"].refresh
- @sprites["battleboxR"].refresh
- @sprites["battleboxL"].refresh
- if showmessage
- trainerName = @battle.pbGetOwner(1).name
- pbDisplayMessage("#{trainerName}'s Pokémon rotated to the left!",true)
- @battle.pbDisplayBrief("")
- end
- end
- def rotateLeft(nextPoke,showmessage = true)
- @sprites["battlebox0"].dispose
- @sprites["battlebox0"]=PokemonDataBox.new(nextPoke,@battle.doublebattle,@viewport)
- @sprites["battlebox0"].appear
- newPokeSprite = PokemonBattlerSprite.new(false,0,@viewport)
- newPokeSprite.setPokemonBitmap(nextPoke.pokemon,true)
- oldX = PokeBattle_SceneConstants::PLAYERBATTLER_X - newPokeSprite.width/2
- oldY = PokeBattle_SceneConstants::PLAYERBATTLER_Y - newPokeSprite.height
- newPokeSprite.x = oldX + 200
- newPokeSprite.y = oldY + 100
- newPokeSprite.z = @sprites["pokemon0"].z
- newPokeSprite.visible = true
- #this is for the battlebox ... wanna do it in the same loop as the animation
- #because I want it both to happen at the same time
- pbWaitMessage
- pbRefresh
- pbShowWindow(MESSAGEBOX)
- cw=@sprites["messagewindow"]
- playerName = @battle.pbGetOwner(0).name
- cw.text="#{playerName}'s Pokémon rotated to the left!"
- loop do
- #break if everything is ready
- if !@sprites["battlebox0"].appearing && newPokeSprite.x <= oldX && !cw.busy?
- break
- end
- #animate Pokémon
- if newPokeSprite.x > oldX
- newPokeSprite.x-=10
- newPokeSprite.y-=5
- @sprites["pokemon0"].x-=10
- @sprites["pokemon0"].y+=5
- end
- @sprites["battlebox0"].update
- #do the text
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- if Input.trigger?(Input::C) || @abortable
- if cw.pausing?
- pbPlayDecisionSE() if !@abortable
- cw.resume
- end
- end
- end
- @sprites["pokemon0"].visible = false
- @sprites["pokemon0"].dispose
- @sprites["pokemon0"] = newPokeSprite
- #@sprites["battlebox1"] = @sprites["battleboxM"]
- end
- def rotateRight(nextPoke, showmessage = true)
- @sprites["battlebox0"].dispose
- @sprites["battlebox0"]=PokemonDataBox.new(nextPoke,@battle.doublebattle,@viewport)
- @sprites["battlebox0"].appear
- newPokeSprite = PokemonBattlerSprite.new(false,0,@viewport)
- newPokeSprite.setPokemonBitmap(nextPoke.pokemon,true)
- oldX = PokeBattle_SceneConstants::PLAYERBATTLER_X - newPokeSprite.width/2
- oldY = PokeBattle_SceneConstants::PLAYERBATTLER_Y - newPokeSprite.height
- newPokeSprite.x = oldX - 200
- newPokeSprite.y = oldY + 100
- newPokeSprite.z = @sprites["pokemon0"].z
- newPokeSprite.visible = true
- #this is for the battlebox ... wanna do it in the same loop as the animation
- #because I want it both to happen at the same time
- pbWaitMessage
- pbRefresh
- pbShowWindow(MESSAGEBOX)
- cw=@sprites["messagewindow"]
- playerName = @battle.pbGetOwner(0).name
- cw.text="#{playerName}'s Pokémon rotated to the right!"
- loop do
- #break if everything is ready
- if !@sprites["battlebox0"].appearing && newPokeSprite.x >= oldX && !cw.busy?
- break
- end
- #animate Pokémon
- if newPokeSprite.x < oldX
- newPokeSprite.x+=10
- newPokeSprite.y-=5
- @sprites["pokemon0"].x+=10
- @sprites["pokemon0"].y+=6
- end
- @sprites["battlebox0"].update
- #do the text
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- if Input.trigger?(Input::C) || @abortable
- if cw.pausing?
- pbPlayDecisionSE() if !@abortable
- cw.resume
- end
- end
- end
- @sprites["pokemon0"].visible = false
- @sprites["pokemon0"].dispose
- @sprites["pokemon0"] = newPokeSprite
- #@sprites["battlebox1"] = @sprites["battleboxM"]
- end
- #the initial thing where all 3 Pokémon are send out
- def pbTrainerSendOutRotationBattle(battlerindex,pkmn)
- @briefmessage=false
- fadeanim=nil
- while inPartyAnimation?; end
- if @showingenemy
- fadeanim=TrainerFadeAnimation.new(@sprites)
- end
- frame=0
- @sprites["pokemon#{battlerindex}"].setPokemonBitmap(pkmn[0].pokemon,false)
- if @battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil #Illusion
- @sprites["pokemon#{battlerindex}"].setPokemonBitmap(
- @battle.battlers[battlerindex].effects[PBEffects::Illusion],false)
- end
- @sprites["pokemonL"]=PokemonBattlerSprite.new(false,1,@viewport)
- @sprites["pokemonL"].setPokemonBitmap(pkmn[1].pokemon,false)
- if @battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil #Illusion
- @sprites["pokemonL"].setPokemonBitmap(
- @battle.battlers[battlerindex].effects[PBEffects::Illusion],false)
- end
- @sprites["pokemonR"]=PokemonBattlerSprite.new(false,1,@viewport)
- @sprites["pokemonR"].setPokemonBitmap(pkmn[2].pokemon,false)
- if @battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil #Illusion
- @sprites["pokemonR"].setPokemonBitmap(
- @battle.battlers[battlerindex].effects[PBEffects::Illusion],false)
- end
- sendout=PokeballSendOutAnimation.new(@sprites["pokemon#{battlerindex}"],
- @sprites,@battle.pokeTrainer[0],@battle.doublebattle,
- @battle.battlers[battlerindex].effects[PBEffects::Illusion]) #Illusion
- sendoutL=PokeballSendOutAnimationRotation.new(@sprites["pokemonL"],
- @sprites,@battle.pokeTrainer[1],
- @battle.battlers[battlerindex].effects[PBEffects::Illusion], #Illusion
- PokeBattle_SceneConstants::FOEBATTLER_X + PokeBattle_SceneConstants::FOEBATTLER_ROT_L_XSHIFT,
- PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBATTLER_ROT_RL_YSHIFT,
- 0.5,"L",self)
- sendoutR=PokeballSendOutAnimationRotation.new(@sprites["pokemonR"],
- @sprites,@battle.pokeTrainer[2],
- @battle.battlers[battlerindex].effects[PBEffects::Illusion], #Illusion
- PokeBattle_SceneConstants::FOEBATTLER_X + PokeBattle_SceneConstants::FOEBATTLER_ROT_R_XSHIFT,
- PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBATTLER_ROT_RL_YSHIFT,
- 0.5,"R",self)
- @sprites["battleboxM"] = PokemonDataBoxRotation.new(pkmn[0],@battle.doublebattle,@viewport,1)
- @sprites["battleboxL"] = PokemonDataBoxRotation.new(pkmn[1],@battle.doublebattle,@viewport,0)
- @sprites["battleboxR"] = PokemonDataBoxRotation.new(pkmn[2],@battle.doublebattle,@viewport,2)
- loop do
- pbGraphicsUpdate
- #ADDED
- pbFrameUpdate(nil)
- #///
- pbInputUpdate
- fadeanim.update if fadeanim
- frame+=1
- if frame==1
- @sprites["battleboxM"].appear
- @sprites["battleboxL"].appear
- @sprites["battleboxR"].appear
- end
- if frame>=10
- sendout.update
- sendoutL.update
- sendoutR.update
- end
- @sprites["battleboxM"].update
- @sprites["battleboxL"].update
- @sprites["battleboxR"].update
- break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
- !@sprites["battleboxM"].appearing
- end
- if @battle.battlers[battlerindex].pokemon.isShiny?
- if @battle.battlers[battlerindex].effects[PBEffects::Illusion] == nil
- pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
- else
- if @battle.battlers[battlerindex].effects[PBEffects::Illusion].isShiny?
- pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
- end
- end
- elsif (@battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil &&
- @battle.battlers[battlerindex].effects[PBEffects::Illusion].isShiny?) #ILLUSION
- pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
- end
- sendout.dispose
- if @showingenemy
- @showingenemy=false
- pbDisposeSprite(@sprites,"trainer")
- pbDisposeSprite(@sprites,"partybarfoe")
- for i in 0...6
- pbDisposeSprite(@sprites,"enemy#{i}")
- end
- end
- pbRefresh
- #this is nessecairy because somehow the shadows disappear if the enemy sprite is too big...
- @sprites["shadow1"].visible = true
- @sprites["shadowL"].visible = true
- @sprites["shadowR"].visible = true
- #some variables because i'm dumb...
- @middle_x = @sprites["pokemon#{battlerindex}"].x
- @middle_y = @sprites["pokemon#{battlerindex}"].y
- @middle_shadow_y = @sprites["shadow1"].y
- @middle_shadow_x = @sprites["shadow1"].x
- @left_x = @sprites["pokemonL"].x
- @left_y = @sprites["pokemonL"].y
- @left_shadow_x = @sprites["shadowL"].x
- @left_shadow_y = @sprites["shadowL"].y
- @right_x = @sprites["pokemonR"].x
- @right_y = @sprites["pokemonR"].y
- @right_shadow_x = @sprites["shadowR"].x
- @right_shadow_y = @sprites["shadowR"].y
- end
- def pbTrainerSendOut(battlerindex,pkmn)
- illusionpoke=@battle.battlers[battlerindex].effects[PBEffects::Illusion]
- @briefmessage=false
- fadeanim=nil
- while inPartyAnimation?; end
- if @showingenemy
- fadeanim=TrainerFadeAnimation.new(@sprites)
- end
- frame=0
- @sprites["pokemon#{battlerindex}"].setPokemonBitmap(pkmn,false)
- if illusionpoke
- @sprites["pokemon#{battlerindex}"].setPokemonBitmap(illusionpoke,false)
- end
- sendout=PokeballSendOutAnimation.new(@sprites["pokemon#{battlerindex}"],
- @sprites,@battle.battlers[battlerindex],illusionpoke,@battle.doublebattle)
- loop do
- fadeanim.update if fadeanim
- frame+=1
- if frame==1
- @sprites["battleboxM"].appear
- end
- if frame>=10
- sendout.update
- end
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
- !@sprites["battleboxM"].appearing
- end
- if @battle.battlers[battlerindex].isShiny? && @battle.battlescene
- pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
- end
- sendout.dispose
- if @showingenemy
- @showingenemy=false
- pbDisposeSprite(@sprites,"trainer")
- pbDisposeSprite(@sprites,"partybarfoe")
- for i in 0...6
- pbDisposeSprite(@sprites,"enemy#{i}")
- end
- end
- pbRefresh
- end
- # alias pbBackdropOriginal pbBackdrop
- #
- # def pbBackdrop
- # if @battle.rotationbattle == true
- # pbRotationBackdrop
- # else
- # pbBackdropOriginal
- # end
- # end
- ROTATIONBOX = 4
- def pbFightMenuRotation(index, rotstate)
- #this is for showing the right rotation arrows ...
- #not altering the real rotstate in the logic...
- pbShowWindowRotation(ROTATIONBOX)
- cw = @sprites["fightrotationwindow"]
- battler=@battle.battlers[index]
- cw.battler=battler
- lastIndex=@lastmove[index]
- if battler.moves[lastIndex].id!=0
- cw.setIndex(lastIndex)
- else
- cw.setIndex(2)
- end
- if cw.index == 0 || cw.index == 1
- cw.setIndex(2)
- end
- cw.megaButton=0
- cw.megaButton=1 if @battle.pbCanMegaEvolve?(index)
- if rotstate == 1
- if !@battle.canRotateRight(rotstate) && !@battle.canRotateLeft(rotstate)
- rotstate = 0
- elsif !@battle.canRotateRight(rotstate)
- rotstate = 2
- elsif !@battle.canRotateLeft(rotstate)
- rotstate = 3
- end
- end
- cw.rotation = rotstate
- pbSelectBattler(index)
- pbRefresh
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- # Update selected command
- if Input.trigger?(Input::LEFT) && (cw.index&1)==1 && !(cw.index == 1 && rotstate == 3)
- pbPlayCursorSE() if cw.setIndex(cw.index-1)
- elsif Input.trigger?(Input::RIGHT) && (cw.index&1)==0 && !(cw.index == 0 && rotstate == 2)
- pbPlayCursorSE() if cw.setIndex(cw.index+1)
- elsif Input.trigger?(Input::UP) && !((cw.index&6)==0) && !(rotstate == 0 && (rotstate&2) == 2)
- if (cw.index == 2 && rotstate == 3)
- cw.setIndex(1)
- elsif (cw.index == 3 && rotstate == 2)
- cw.setIndex()
- else
- pbPlayCursorSE() if cw.setIndex(cw.index-2)
- end
- elsif Input.trigger?(Input::DOWN) && !((cw.index&4)==4)
- pbPlayCursorSE() if cw.setIndex(cw.index+2)
- end
- if Input.trigger?(Input::C) # Confirm choice
- ret=cw.index
- pbPlayDecisionSE()
- @lastmove[index]=ret
- pbShowWindowRotation(BLANK)
- return ret
- elsif Input.trigger?(Input::A) # Use Mega Evolution
- if @battle.pbCanMegaEvolve?(index)
- @battle.pbRegisterMegaEvolution(index)
- cw.megaButton=2
- pbPlayDecisionSE()
- end
- elsif Input.trigger?(Input::B) # Cancel fight menu
- @lastmove[index]=cw.index
- pbPlayCancelSE()
- pbShowWindowRotation(BLANK)
- return -1
- end
- end
- end
- def pbShowWindowRotation(windowtype)
- if windowtype==ROTATIONBOX && !@sprites["fightrotationwindow"]
- @sprites["fightrotationwindow"]=FightRotationMenuDisplay.new(nil,@viewport)
- @sprites["fightrotationwindow"].z=100
- end
- @sprites["messagebox"].visible = (windowtype==MESSAGEBOX ||
- windowtype==COMMANDBOX ||
- windowtype==FIGHTBOX ||
- windowtype==BLANK ||
- windowtype==ROTATIONBOX)
- @sprites["messagewindow"].visible = (windowtype==MESSAGEBOX)
- @sprites["commandwindow"].visible = (windowtype==COMMANDBOX)
- @sprites["fightwindow"].visible = (windowtype==FIGHTBOX)
- @sprites["fightrotationwindow"].visible = (windowtype==ROTATIONBOX)
- end
- def pbBackdrop
- environ=@battle.environment
- # Choose backdrop
- backdrop="Field"
- if environ==PBEnvironment::Cave
- backdrop="Cave"
- elsif environ==PBEnvironment::MovingWater || environ==PBEnvironment::StillWater
- backdrop="Water"
- elsif environ==PBEnvironment::Underwater
- backdrop="Underwater"
- elsif environ==PBEnvironment::Rock
- backdrop="Mountain"
- else
- if !$game_map || !pbGetMetadata($game_map.map_id,MetadataOutdoor)
- backdrop="IndoorA"
- end
- end
- if $game_map
- back=pbGetMetadata($game_map.map_id,MetadataBattleBack)
- if back && back!=""
- backdrop=back
- end
- end
- if $PokemonGlobal && $PokemonGlobal.nextBattleBack
- backdrop=$PokemonGlobal.nextBattleBack
- end
- # Choose bases
- base=""
- trialname=""
- if environ==PBEnvironment::Grass || environ==PBEnvironment::TallGrass
- trialname="Grass"
- elsif environ==PBEnvironment::Sand
- trialname="Sand"
- elsif $PokemonGlobal.surfing
- trialname="Water"
- end
- if pbResolveBitmap(sprintf("Graphics/Battlebacks/playerbase"+backdrop+trialname))
- base=trialname
- end
- # Choose time of day
- time=""
- if ENABLESHADING
- trialname=""
- timenow=pbGetTimeNow
- if PBDayNight.isNight?(timenow)
- trialname="Night"
- elsif PBDayNight.isEvening?(timenow)
- trialname="Eve"
- end
- if pbResolveBitmap(sprintf("Graphics/Battlebacks/battlebg"+backdrop+trialname))
- time=trialname
- end
- end
- # Apply graphics
- battlebg="Graphics/Battlebacks/battlebg"+backdrop+time
- #enemybase="Graphics/Battlebacks/enemybase"+backdrop+base+time
- enemybase="Graphics/Battlebacks/enemybaseRotation"
- playerbase="Graphics/Battlebacks/playerbase"+backdrop+base+time
- pbAddPlane("battlebg",battlebg,@viewport)
- pbAddSprite("playerbase",
- PokeBattle_SceneConstants::PLAYERBASEX,
- PokeBattle_SceneConstants::PLAYERBASEY,playerbase,@viewport)
- @sprites["playerbase"].x-=@sprites["playerbase"].bitmap.width/2 if @sprites["playerbase"].bitmap!=nil
- @sprites["playerbase"].y-=@sprites["playerbase"].bitmap.height if @sprites["playerbase"].bitmap!=nil
- pbAddSprite("enemybase",
- PokeBattle_SceneConstants::FOEBATTLER_X + PokeBattle_SceneConstants::FOEBASE_ROT_XSHIFT,
- PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBASE_ROT_YSHIFT,enemybase,@viewport)
- @sprites["enemybase"].x-=@sprites["enemybase"].bitmap.width/2 if @sprites["enemybase"].bitmap!=nil
- @sprites["enemybase"].y-=@sprites["enemybase"].bitmap.height/2 if @sprites["enemybase"].bitmap!=nil
- @sprites["battlebg"].z=0
- @sprites["playerbase"].z=1
- @sprites["enemybase"].z=1
- end
- # Use this method to display the inventory
- # The return value is the item chosen, or 0 if the choice was canceled.
- #TODO alter to where all 3 battlers are affected
- def pbItemMenu(index)
- ret=0
- retindex=-1
- pkmnid=-1
- endscene=true
- oldsprites=pbFadeOutAndHide(@sprites)
- itemscene=PokemonBag_Scene.new
- itemscene.pbStartScene($PokemonBag)
- loop do
- item=itemscene.pbChooseItem
- break if item==0
- usetype=$ItemData[item][ITEMBATTLEUSE]
- cmdUse=-1
- commands=[]
- if usetype==0
- commands[commands.length]=_INTL("Cancel")
- else
- commands[cmdUse=commands.length]=_INTL("Use")
- commands[commands.length]=_INTL("Cancel")
- end
- itemname=PBItems.getName(item)
- command=itemscene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
- if cmdUse>=0 && command==cmdUse
- if usetype==1 || usetype==3
- modparty=[]
- for i in 0...6
- modparty.push(@battle.party1[@battle.party1order[i]])
- end
- pkmnlist=PokemonScreen_Scene.new
- pkmnscreen=PokemonScreen.new(pkmnlist,modparty)
- itemscene.pbEndScene
- pkmnscreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.doublebattle)
- activecmd=pkmnscreen.pbChoosePokemon
- pkmnid=@battle.party1order[activecmd]
- if activecmd>=0 && pkmnid>=0 && ItemHandlers.hasBattleUseOnPokemon(item)
- pkmnlist.pbEndScene
- ret=item
- retindex=pkmnid
- endscene=false
- break
- end
- pkmnlist.pbEndScene
- itemscene.pbStartScene($PokemonBag)
- elsif usetype==2 || usetype==4
- #this is if the item is used on an active Pokémon which requires
- #asking the player for a target
- #loosing a round if you choose a wrong target is on purpose
- if ItemHandlers.hasBattleUseOnBattler(item)
- modparty=[]
- for i in 0...6
- modparty.push(@battle.party1[@battle.party1order[i]])
- end
- pkmnlist=PokemonScreen_Scene.new
- pkmnscreen=PokemonScreen.new(pkmnlist,modparty)
- itemscene.pbEndScene
- pkmnscreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.doublebattle)
- activecmd=pkmnscreen.pbChoosePokemon
- pkmnid=@battle.party1order[activecmd]
- if activecmd>=0 && pkmnid>=0 #Pokémon selected
- pkmnlist.pbEndScene
- ret=item
- retindex=pkmnid
- endscene=false
- break
- end
- #canceled
- pkmnlist.pbEndScene
- itemscene.pbStartScene($PokemonBag)
- end
- end
- end
- end
- pbConsumeItemInBattle($PokemonBag,ret) if ret>0
- itemscene.pbEndScene if endscene
- pbFadeInAndShow(@sprites,oldsprites)
- return [ret,retindex]
- end
- def pbCommonAnimation(animname,user,target,hitnum=0)
- if(user != @battle.pokePlayer[0] && user != @battle.pokeTrainer[0])
- return #don't show aimation if the Pokémon is not in the middle
- end
- animations=load_data("Data/PkmnAnimations.rxdata")
- for i in 0...animations.length
- if animations[i] && animations[i].name=="Common:"+animname
- pbAnimationCore(animations[i],user,(target!=nil) ? target : user)
- return
- end
- end
- end
- # This method is called whenever a Pokémon's HP changes.
- # Used to animate the HP bar.
- #changed to work on both battlers battleboxes(changed naming conventions...)
- def pbHPChanged(pkmn,oldhp,anim=false)
- @briefmessage=false
- hpchange=pkmn.hp-oldhp
- if hpchange<0
- hpchange=-hpchange
- PBDebug.log("[HP change] #{pkmn.pbThis} lost #{hpchange} HP (#{oldhp}=>#{pkmn.hp})")
- else
- PBDebug.log("[HP change] #{pkmn.pbThis} gained #{hpchange} HP (#{oldhp}=>#{pkmn.hp})")
- end
- if anim && @battle.battlescene
- if pkmn.hp>oldhp
- pbCommonAnimation("HealthUp",pkmn,nil)
- elsif pkmn.hp<oldhp
- pbCommonAnimation("HealthDown",pkmn,nil)
- end
- end
- sprite= pkmn.index == 0 ? @sprites["battlebox0"]:@sprites["battleboxM"]
- sprite.animateHP(oldhp,pkmn.hp)
- while sprite.animatingHP
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- sprite.update
- end
- end
- # This method is called whenever a Pokémon faints.
- def pbFainted(pkmn)
- frames=pbCryFrameLength(pkmn.pokemon)
- pbPlayCry(pkmn.pokemon)
- frames.times do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- end
- @sprites["shadow#{pkmn.index}"].visible=false
- pkmnsprite=@sprites["pokemon#{pkmn.index}"]
- ycoord=0
- if @battle.doublebattle
- ycoord=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if pkmn.index==0
- ycoord=PokeBattle_SceneConstants::FOEBATTLERD1_Y if pkmn.index==1
- ycoord=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if pkmn.index==2
- ycoord=PokeBattle_SceneConstants::FOEBATTLERD2_Y if pkmn.index==3
- else
- if @battle.pbIsOpposing?(pkmn.index)
- ycoord=PokeBattle_SceneConstants::FOEBATTLER_Y
- else
- ycoord=PokeBattle_SceneConstants::PLAYERBATTLER_Y
- end
- end
- pbSEPlay("faint")
- loop do
- pkmnsprite.y+=8
- if pkmnsprite.y-pkmnsprite.oy+pkmnsprite.src_rect.height>=ycoord
- pkmnsprite.src_rect.height=ycoord-pkmnsprite.y+pkmnsprite.oy
- end
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if pkmnsprite.y>=ycoord
- end
- pkmnsprite.visible=false
- battlebox = pkmn.index == 0 ? @sprites["battlebox0"] : @sprites["battleboxM"]
- 8.times do
- battlebox.opacity-=32
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- end
- battlebox.visible=false
- pkmn.pbResetForm
- end
- end
- #send out the other pkmn
- class PokeballSendOutAnimationRotation
- #initializes the class and throws a pokemon to the position assigned
- def initialize(sprite,spritehash,pkmn,illusionpoke,x,y,zoom,nameExtension,scene)
- @disposed=false
- @pkmn = pkmn
- @ballused=pkmn.pokemon ? pkmn.pokemon.ballused : 0
- @PokemonBattlerSprite=sprite
- @PokemonBattlerSprite.visible=false
- @PokemonBattlerSprite.tone=Tone.new(248,248,248,248)
- @PokemonBattlerSprite.y=0
- @pokeballsprite=IconSprite.new(0,0,sprite.viewport)
- @pokeballsprite.setBitmap(sprintf("Graphics/Pictures/ball%02d",@ballused))
- @viewport = scene.viewport
- @scene = scene
- @zoom = zoom
- @spritex=x
- @spritey=y
- @illusionpoke = illusionpoke #ILLUSION
- if illusionpoke != nil #ILLUSION
- #@spritey+=adjustBattleSpriteY(sprite,illusionpoke.species,pkmn.index,nil,true,illusionpoke.formOffsetY)
- else
- #@spritey+=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index,nil,true,pkmn.formOffsetY)
- end #ILLUSION
- @endspritey=@spritey
- @spritehash=spritehash
- @pokeballsprite.x=@spritex-@pokeballsprite.bitmap.width/2
- @pokeballsprite.y=@spritey-@pokeballsprite.bitmap.height/2-4
- @pokeballsprite.z=@PokemonBattlerSprite.z+1
- @pkmn=pkmn
- @shadowName = "shadow" + nameExtension
- @shadowX=@spritex
- @shadowY=PokeBattle_SceneConstants::FOEBASEY + PokeBattle_SceneConstants::FOESHADOW_ROT_RL_YSHIFT
- @scene.pbAddSprite(@shadowName,@shadowX,@shadowY,"Graphics/Pictures/battleShadow",
- @viewport)
- if @spritehash[@shadowName] && @spritehash[@shadowName].bitmap!=nil
- @spritehash[@shadowName].z=2
- @shadowX-=@spritehash[@shadowName].bitmap.width/2
- @shadowY-=@spritehash[@shadowName].bitmap.height/2
- @spritehash[@shadowName].x=@shadowX
- @spritehash[@shadowName].y=@shadowY
- end
- if illusionpoke != nil #ILLUSION
- @shadowVisible=showShadow?(illusionpoke.species)
- else
- @shadowVisible=showShadow?(pkmn.species)
- end #ILLUSION
- @stepspritey=(@spritey-@endspritey)
- @stepspritey=(@spritey-@endspritey)
- @zoomstep=(1.0-STARTZOOM)/SPRITESTEPS * @zoom
- @animdone=false
- @frame=0
- end
- def disposed?
- return @disposed
- end
- def animdone?
- return @animdone
- end
- def dispose
- return if disposed?
- @pokeballsprite.dispose
- @disposed=true
- end
- def update
- return if disposed?
- @pokeballsprite.update
- @frame+=1
- if @frame==2
- pbSEPlay("recall")
- end
- if @frame==4
- @PokemonBattlerSprite.visible=true
- @PokemonBattlerSprite.z=26
- @PokemonBattlerSprite.zoom_x=STARTZOOM * @zoom
- @PokemonBattlerSprite.zoom_y=STARTZOOM * @zoom
- pbSpriteSetCenter(@PokemonBattlerSprite,@spritex,@spritey)
- if @illusionpoke != nil #ILLUSION
- pbPlayCry(@illusionpoke)
- else
- pbPlayCry(@pkmn.pokemon ? @pkmn.pokemon : @pkmn.species)
- end #ILLUSION
- @pokeballsprite.setBitmap(sprintf("Graphics/Pictures/ball%02d_open",@ballused))
- end
- if @frame==8
- @pokeballsprite.visible=false
- end
- if @frame>8 && @frame<=16
- color=Color.new(248,248,248,256-(16-@frame)*32)
- @spritehash["enemybase"].color=color
- @spritehash["playerbase"].color=color
- @spritehash["battlebg"].color=color
- for i in 0...4
- @spritehash["shadow#{i}"].color=color if @spritehash["shadow#{i}"]
- end
- @spritehash[@shadowName].color=color if @spritehash[@shadowName]
- end
- if @frame>16 && @frame<=24
- color=Color.new(248,248,248,(24-@frame)*32)
- tone=(24-@frame)*32
- @PokemonBattlerSprite.tone=Tone.new(tone,tone,tone,tone)
- @spritehash["enemybase"].color=color
- @spritehash["playerbase"].color=color
- @spritehash["battlebg"].color=color
- for i in 0...4
- @spritehash["shadow#{i}"].color=color if @spritehash["shadow#{i}"]
- end
- @spritehash[@shadowName].color=color if @spritehash[@shadowName]
- end
- #CHANGED
- if @frame>5 && @PokemonBattlerSprite.zoom_x<BATTLERZOOM * @zoom
- @PokemonBattlerSprite.zoom_x+=@zoomstep
- @PokemonBattlerSprite.zoom_y+=@zoomstep
- @PokemonBattlerSprite.zoom_x=BATTLERZOOM * @zoom if @PokemonBattlerSprite.zoom_x > BATTLERZOOM * @zoom
- @PokemonBattlerSprite.zoom_y=BATTLERZOOM * @zoom if @PokemonBattlerSprite.zoom_y > BATTLERZOOM * @zoom
- #currentY=@spritey - @PokemonBattlerSprite.height*@PokemonBattlerSprite.zoom_y
- currentY = adjustBattleSpriteY(@PokemonBattlerSprite,@pkmn.pokemon.species,1)*@PokemonBattlerSprite.zoom_y
- currentY += PokeBattle_SceneConstants::FOEBATTLER_Y + PokeBattle_SceneConstants::FOEBATTLER_ROT_RL_YSHIFT
- @PokemonBattlerSprite.x=@spritex - @PokemonBattlerSprite.width*@PokemonBattlerSprite.zoom_x/2
- @PokemonBattlerSprite.y=currentY
- end
- if @PokemonBattlerSprite.tone.gray<=0 && @PokemonBattlerSprite.zoom_x>=BATTLERZOOM * @zoom
- #///
- @animdone=true
- if @spritehash[@shadowName]
- @spritehash[@shadowName].x=@shadowX
- @spritehash[@shadowName].y=@shadowY
- @spritehash[@shadowName].visible=@shadowVisible
- end
- end
- end
- end
- #the moves/rotation/mega selection
- class FightRotationMenuDisplay
- attr_reader :battler
- attr_reader :index
- attr_accessor :megaButton
- attr_accessor :rotation
- def initialize(battler,viewport=nil)
- @display=nil
- if PokeBattle_SceneConstants::USEFIGHTBOX
- @display=IconSprite.new(0,Graphics.height-96,viewport)
- @display.setBitmap("Graphics/Pictures/battleFight")
- end
- @window=Window_CommandPokemon.newWithSize([],0,Graphics.height-96,320,96,viewport)
- @window.columns=2
- @window.columnSpacing=4
- @window.ignore_input=true
- pbSetNarrowFont(@window.contents)
- @info=Window_AdvancedTextPokemon.newWithSize(
- "",320,Graphics.height-96,Graphics.width-320,96,viewport)
- pbSetNarrowFont(@info.contents)
- @ctag=shadowctag(PokeBattle_SceneConstants::MENUBASECOLOR,
- PokeBattle_SceneConstants::MENUSHADOWCOLOR)
- @buttons=nil
- @battler=battler
- @index=0
- @megaButton=0 # 0=don't show, 1=show, 2=pressed
- @rotation=1 #0=don't show, 1=rotate both sides, 2=rotate left only, 3=rotate right only
- if PokeBattle_SceneConstants::USEFIGHTBOX
- @window.opacity=0
- @window.x=Graphics.width
- @info.opacity=0
- @info.x=Graphics.width+Graphics.width-96
- @buttons=FightRotationMenuButtons.new(self.index,nil,viewport)
- end
- refresh
- end
- def x; @window.x; end
- def x=(value)
- @window.x=value
- @info.x=value
- @display.x=value if @display
- @buttons.x=value if @buttons
- end
- def y; @window.y; end
- def y=(value)
- @window.y=value
- @info.y=value
- @display.y=value if @display
- @buttons.y=value if @buttons
- end
- def z; @window.z; end
- def z=(value)
- @window.z=value
- @info.z=value
- @display.z=value if @display
- @buttons.z=value+1 if @buttons
- end
- def ox; @window.ox; end
- def ox=(value)
- @window.ox=value
- @info.ox=value
- @display.ox=value if @display
- @buttons.ox=value if @buttons
- end
- def oy; @window.oy; end
- def oy=(value)
- @window.oy=value
- @info.oy=value
- @display.oy=value if @display
- @buttons.oy=value if @buttons
- end
- def visible; @window.visible; end
- def visible=(value)
- @window.visible=value
- @info.visible=value
- @display.visible=value if @display
- @buttons.visible=value if @buttons
- end
- def color; @window.color; end
- def color=(value)
- @window.color=value
- @info.color=value
- @display.color=value if @display
- @buttons.color=value if @buttons
- end
- def disposed?
- return @info.disposed? || @window.disposed?
- end
- def dispose
- return if disposed?
- @info.dispose
- @display.dispose if @display
- @buttons.dispose if @buttons
- @window.dispose
- end
- def battler=(value)
- @battler=value
- refresh
- end
- def setIndex(value)
- if @battler && (@battler.moves[value].id!=0 || value > 4)
- @index=value
- @window.index=value
- refresh
- return true
- end
- return false
- end
- def refresh
- return if !@battler
- commands=[]
- for i in 0...4
- break if @battler.moves[i].id==0
- commands.push(@battler.moves[i].name)
- end
- @window.commands=commands
- selmove=@battler.moves[@index-2]
- movetype=PBTypes.getName(selmove.type)
- if selmove.totalpp==0
- @info.text=_ISPRINTF("{1:s}PP: ---<br>TYPE/{2:s}",@ctag,movetype)
- else
- @info.text=_ISPRINTF("{1:s}PP: {2: 2d}/{3: 2d}<br>TYPE/{4:s}",
- @ctag,selmove.pp,selmove.totalpp,movetype)
- end
- end
- def update
- @info.update
- @window.update
- @display.update if @display
- if @buttons
- moves=@battler ? @battler.moves : nil
- @buttons.update(self.index,moves,@megaButton,@rotation)
- end
- end
- end
- #actually show the fight buttons
- class FightRotationMenuButtons < BitmapSprite
- UPPERGAP=46
- def initialize(index=0,moves=nil,viewport=nil)
- super(Graphics.width,96+UPPERGAP,viewport)
- self.x=0
- self.y=Graphics.height-96-UPPERGAP
- pbSetNarrowFont(self.bitmap)
- @buttonbitmap=AnimatedBitmap.new("Graphics/Pictures/battleFightButtons")
- @typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
- @megaevobitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleMegaEvo"))
- @rotleftbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleRotateLeft"))
- @rotrightbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleRotateRight"))
- refresh(index,moves,0,0)
- end
- def dispose
- @buttonbitmap.dispose
- @typebitmap.dispose
- @megaevobitmap.dispose
- @rotleftbitmap.dispose
- @rotrightbitmap.dispose
- super
- end
- def update(index=0,moves=nil,megaButton=0,rotationbattle=1)
- refresh(index,moves,megaButton,rotationbattle)
- end
- def refresh(index,moves,megaButton,rotationbattle)
- return if !moves
- self.bitmap.clear
- moveboxes=_INTL("Graphics/Pictures/battleFightButtons")
- textpos=[]
- for i in 0...4
- next if i==index-2
- next if moves[i].id==0
- x=((i%2)==0) ? 4 : 192
- y=((i/2)==0) ? 6 : 48
- y+=UPPERGAP
- self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(0,moves[i].type*46,192,46))
- textpos.push([_INTL("{1}",moves[i].name),x+96,y+8,2,
- PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
- end
- ppcolors=[
- PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
- PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
- PokeBattle_SceneConstants::PPTEXTBASECOLORYELLOW,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORYELLOW,
- PokeBattle_SceneConstants::PPTEXTBASECOLORORANGE,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORORANGE,
- PokeBattle_SceneConstants::PPTEXTBASECOLORRED,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORRED
- ]
- for i in 0...4
- next if i!=index-2
- next if moves[i].id==0
- x=((i%2)==0) ? 4 : 192
- y=((i/2)==0) ? 6 : 48
- y+=UPPERGAP
- self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(192,moves[i].type*46,192,46))
- self.bitmap.blt(416,20+UPPERGAP,@typebitmap.bitmap,Rect.new(0,moves[i].type*28,64,28))
- textpos.push([_INTL("{1}",moves[i].name),x+96,y+8,2,
- PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
- if moves[i].totalpp>0
- ppfraction=(4.0*moves[i].pp/moves[i].totalpp).ceil
- textpos.push([_INTL("PP: {1}/{2}",moves[i].pp,moves[i].totalpp),
- 448,50+UPPERGAP,2,ppcolors[(4-ppfraction)*2],ppcolors[(4-ppfraction)*2+1]])
- end
- end
- pbDrawTextPositions(self.bitmap,textpos)
- if megaButton>0
- self.bitmap.blt(146,0,@megaevobitmap.bitmap,Rect.new(0,(megaButton-1)*46,96,46))
- end
- #show rotation buttons
- case rotationbattle
- when 0
- when 1
- self.bitmap.blt(0,0,@rotleftbitmap.bitmap,Rect.new(0,54,54,54))
- self.bitmap.blt(54,0,@rotrightbitmap.bitmap,Rect.new(0,54,54,54))
- if index == 0
- self.bitmap.blt(0,0,@rotleftbitmap.bitmap,Rect.new(0,108,54,54))
- end
- if index == 1
- self.bitmap.blt(54,0,@rotrightbitmap.bitmap,Rect.new(0,108,54,54))
- end
- when 2
- self.bitmap.blt(0,0,@rotleftbitmap.bitmap,Rect.new(0,54,54,54))
- self.bitmap.blt(54,0,@rotrightbitmap.bitmap,Rect.new(0,0,54,54))
- if index == 0 #shouldn't happen ...
- self.bitmap.blt(0,0,@rotleftbitmap.bitmap,Rect.new(0,108,54,54))
- end
- if index == 1
- self.bitmap.blt(54,0,@rotrightbitmap.bitmap,Rect.new(0,108,54,54))
- end
- when 3
- self.bitmap.blt(0,0,@rotleftbitmap.bitmap,Rect.new(0,0,54,54))
- self.bitmap.blt(54,0,@rotrightbitmap.bitmap,Rect.new(0,54,54,54))
- if index == 0
- self.bitmap.blt(0,0,@rotleftbitmap.bitmap,Rect.new(0,108,54,54))
- end
- if index == 1 #shouldn't happen ...
- self.bitmap.blt(54,0,@rotrightbitmap.bitmap,Rect.new(0,108,54,54))
- end
- end
- end
- end
- #databox for the enemy
- class PokemonDataBoxRotation < SpriteWrapper
- attr_accessor :place #0 left, 1 middle, 2 right
- attr_reader :battler
- attr_accessor :selected
- attr_accessor :appearing
- attr_reader :animatingHP
- def initialize(battler,doublebattle,viewport=nil,place=0)
- super(viewport)
- @place = place
- @battler=battler
- @selected=0
- @frame=0
- @showhp=false
- @appearing=false
- @animatingHP=false
- @starthp=0
- @currenthp=0
- @endhp=0
- if (@battler.index&1)==0 # if player's Pokémon
- @spritebaseX=34
- else
- @spritebaseX=16
- end
- @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxS")
- @spriteX=PokeBattle_SceneConstants::FOEBOX_X
- @spriteY=@place * @databox.bitmap.height
- @statuses=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleStatuses"))
- @contents=BitmapWrapper.new(@databox.width,@databox.height)
- self.bitmap=@contents
- self.visible=false
- self.z=50
- refresh
- end
- def dispose
- @statuses.dispose
- @databox.dispose
- @contents.dispose
- super
- end
- def hp
- return @animatingHP ? @currenthp : @battler.hp
- end
- def animateHP(oldhp,newhp)
- @starthp=oldhp
- @currenthp=oldhp
- @endhp=newhp
- @animatingHP=true
- end
- def appear
- refresh
- self.visible=true
- self.opacity=255
- if (@battler.index&1)==0 # if player's Pokémon
- self.x=@spriteX+320
- else
- self.x=@spriteX-320
- end
- self.y=@spriteY
- @appearing=true
- end
- def refresh
- self.bitmap.clear
- return if !@battler.pokemon
- self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
- base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
- shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
- pokename=@battler.name
- pbSetSystemFont(self.bitmap)
- textpos=[
- [pokename,@spritebaseX+8,6,false,base,shadow]
- ]
- genderX=self.bitmap.text_size(pokename).width
- genderX+=@spritebaseX+14
- case @battler.displayGender
- when 0 # Male
- textpos.push([_INTL("♂"),genderX,6,false,Color.new(48,96,216),shadow])
- when 1 # Female
- textpos.push([_INTL("♀"),genderX,6,false,Color.new(248,88,40),shadow])
- end
- pbDrawTextPositions(self.bitmap,textpos)
- pbSetSmallFont(self.bitmap)
- textpos=[
- [_INTL("Lv{1}",@battler.level),@spritebaseX+202,8,true,base,shadow]
- ]
- if @showhp
- hpstring=_ISPRINTF("{1: 2d}/{2: 2d}",self.hp,@battler.totalhp)
- textpos.push([hpstring,@spritebaseX+188,48,true,base,shadow])
- end
- pbDrawTextPositions(self.bitmap,textpos)
- imagepos=[]
- if @battler.isShiny?
- shinyX=206
- shinyX=-6 if (@battler.index&1)==0 # If player's Pokémon
- imagepos.push(["Graphics/Pictures/shiny.png",@spritebaseX+shinyX,36,0,0,-1,-1])
- end
- if @battler.isMega?
- imagepos.push(["Graphics/Pictures/battleMegaEvoBox.png",@spritebaseX+8,34,0,0,-1,-1])
- elsif @battler.isPrimal?
- if isConst?(@battler.pokemon.species,PBSpecies,:KYOGRE)
- imagepos.push(["Graphics/Pictures/battlePrimalKyogreBox.png",@spritebaseX+140,4,0,0,-1,-1])
- elsif isConst?(@battler.pokemon.species,PBSpecies,:GROUDON)
- imagepos.push(["Graphics/Pictures/battlePrimalGroudonBox.png",@spritebaseX+140,4,0,0,-1,-1])
- end
- end
- if @battler.owned && (@battler.index&1)==1
- imagepos.push(["Graphics/Pictures/battleBoxOwned.png",@spritebaseX+8,36,0,0,-1,-1])
- end
- pbDrawImagePositions(self.bitmap,imagepos)
- if @battler.status>0
- self.bitmap.blt(@spritebaseX+24,36,@statuses.bitmap,
- Rect.new(0,(@battler.status-1)*16,44,16))
- end
- hpGaugeSize=PokeBattle_SceneConstants::HPGAUGESIZE
- hpgauge=@battler.totalhp==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
- hpgauge=2 if hpgauge==0 && self.hp>0
- hpzone=0
- hpzone=1 if self.hp<=(@battler.totalhp/2).floor
- hpzone=2 if self.hp<=(@battler.totalhp/4).floor
- hpcolors=[
- PokeBattle_SceneConstants::HPCOLORGREENDARK,
- PokeBattle_SceneConstants::HPCOLORGREEN,
- PokeBattle_SceneConstants::HPCOLORYELLOWDARK,
- PokeBattle_SceneConstants::HPCOLORYELLOW,
- PokeBattle_SceneConstants::HPCOLORREDDARK,
- PokeBattle_SceneConstants::HPCOLORRED
- ]
- # fill with black (shows what the HP used to be)
- hpGaugeX=PokeBattle_SceneConstants::HPGAUGE_X
- hpGaugeY=PokeBattle_SceneConstants::HPGAUGE_Y
- if @animatingHP && self.hp>0
- self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY,
- @starthp*hpGaugeSize/@battler.totalhp,6,Color.new(0,0,0))
- end
- # fill with HP color
- self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY,hpgauge,2,hpcolors[hpzone*2])
- self.bitmap.fill_rect(@spritebaseX+hpGaugeX,hpGaugeY+2,hpgauge,4,hpcolors[hpzone*2+1])
- end
- def update
- super
- @frame+=1
- if @animatingHP
- if @currenthp<@endhp
- @currenthp+=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor].max
- @currenthp=@endhp if @currenthp>@endhp
- elsif @currenthp>@endhp
- @currenthp-=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor].max
- @currenthp=@endhp if @currenthp<@endhp
- end
- @animatingHP=false if @currenthp==@endhp
- refresh
- end
- if @appearing
- if (@battler.index&1)==0 # if player's Pokémon
- self.x-=12
- self.x=@spriteX if self.x<@spriteX
- @appearing=false if self.x<=@spriteX
- else
- self.x+=12
- self.x=@spriteX if self.x>@spriteX
- @appearing=false if self.x>=@spriteX
- end
- self.y=@spriteY
- return
- end
- @spriteY=@place * @databox.bitmap.height
- self.x=@spriteX
- self.y=@spriteY
- # Data box bobbing while Pokémon is selected
- if ((@frame/10).floor&1)==1 && @selected==1 # Choosing commands for this Pokémon
- self.y=@spriteY+2
- elsif ((@frame/10).floor&1)==1 && @selected==2 # When targeted or damaged
- self.y=@spriteY+2
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement