Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################################################################
- # Party Plus V2.1 #
- # By PokeMiner20 #
- #This script allows for the modification of the number of pokemon a player can #
- #bring with them. it provedes 23 different party limits to use, and it all can #
- #be done by using one single command. To activate the Script, use the command #
- #$Trainer.partyplus='#' in a script and replace '#' with any of the following #
- #numbers: 1,2,3,4,5,8,9,10,12,14,15,16,18,20,2124,25,26,30,32,35, or 40. any #
- #other number (Save perhaps 6) will result in an error in some sort, not right #
- #after changing the limit but in using the party list (No I will not look into #
- #why) As an added bonus, this script will also allow opponents to use more than#
- #6 pokemon, however they are not limited to the numbers not included above. a #
- #few of the things this doesn't do for you is alter the Hall of Fame, the Joy #
- #Healing Animation, or the continue screen inages, so be aware of that when #
- #using this. Also, because of lazyness you will not be able to see the simple #
- #stats of the pokemon in the Party Menu, this script is already huge as is. #
- #Please give credit if you do, and enjoy this script. ~PDM20#
- ################################################################################
- # Trainer Modification
- ################################################################################
- class PokeBattle_Trainer
- attr_accessor(:name)
- attr_accessor(:id)
- attr_accessor(:metaID)
- attr_accessor(:trainertype)
- attr_accessor(:outfit)
- attr_accessor(:badges)
- attr_accessor(:money)
- attr_accessor(:seen)
- attr_accessor(:owned)
- attr_accessor(:formseen)
- attr_accessor(:formlastseen)
- attr_accessor(:shadowcaught)
- attr_accessor(:party)
- attr_accessor(:pokedex) # Whether the Pokédex was obtained
- attr_accessor(:pokegear) # Whether the Pokégear was obtained
- attr_accessor(:language)
- attr_accessor(:partyplus)
- def trainerTypeName # Name of this trainer type (localized)
- return PBTrainers.getName(@trainertype) rescue _INTL("PkMn Trainer")
- end
- def fullname
- return _INTL("{1} {2}",self.trainerTypeName,@name)
- end
- def publicID(id=nil) # Portion of the ID which is visible on the Trainer Card
- return id ? id&0xFFFF : @id&0xFFFF
- end
- def secretID(id=nil) # Other portion of the ID
- return id ? id>>16 : @id>>16
- end
- def getForeignID # Random ID other than this Trainer's ID
- fid=0
- loop do
- fid=rand(256)
- fid|=rand(256)<<8
- fid|=rand(256)<<16
- fid|=rand(256)<<24
- break if fid!=@id
- end
- return fid
- end
- def setForeignID(other)
- @id=other.getForeignID
- end
- def metaID
- @metaID=$PokemonGlobal.playerID if !@metaID && $PokemonGlobal
- @metaID=0 if !@metaID
- return @metaID
- end
- def outfit
- @outfit=0 if !@outfit
- return @outfit
- end
- def partyplus
- @partyplus=0 if !@partyplus
- return @partyplus
- end
- def language
- @language=pbGetLanguage() if !@language
- return @language
- end
- def money=(value)
- @money=[[value,MAXMONEY].min,0].max
- end
- def moneyEarned # Money won when trainer is defeated
- ret=0
- pbRgssOpen("Data/trainertypes.dat","rb"){|f|
- trainertypes=Marshal.load(f)
- return 30 if !trainertypes[@trainertype]
- ret=trainertypes[@trainertype][3]
- }
- return ret
- end
- def skill # Skill level (for AI)
- ret=0
- pbRgssOpen("Data/trainertypes.dat","rb"){|f|
- trainertypes=Marshal.load(f)
- return 30 if !trainertypes[@trainertype]
- ret=trainertypes[@trainertype][8]
- }
- return ret
- end
- def skillCode
- ret=""
- pbRgssOpen("Data/trainertypes.dat","rb"){|f|
- trainertypes=Marshal.load(f)
- return "" if !trainertypes[@trainertype]
- ret=trainertypes[@trainertype][9]
- }
- return ret
- end
- def hasSkillCode(code)
- c=skillCode
- return true if c!=nil && c!="" && c[/#{code}/]
- return false
- end
- def numbadges # Number of badges
- ret=0
- for i in 0...@badges.length
- ret+=1 if @badges[i]
- end
- return ret
- end
- def gender
- ret=2 # 2 = gender unknown
- pbRgssOpen("Data/trainertypes.dat","rb"){|f|
- trainertypes=Marshal.load(f)
- if !trainertypes || !trainertypes[trainertype]
- ret=2
- else
- ret=trainertypes[trainertype][7]
- ret=2 if !ret
- end
- }
- return ret
- end
- def isMale?; return self.gender==0; end
- def isFemale?; return self.gender==1; end
- def pokemonParty
- return @party.find_all {|item| item && !item.egg? }
- end
- def ablePokemonParty
- return @party.find_all {|item| item && !item.egg? && item.hp>0 }
- end
- def partyCount
- return @party.length
- end
- def pokemonCount
- ret=0
- for i in 0...@party.length
- ret+=1 if @party[i] && !@party[i].egg?
- end
- return ret
- end
- def ablePokemonCount
- ret=0
- for i in 0...@party.length
- ret+=1 if @party[i] && !@party[i].egg? && @party[i].hp>0
- end
- return ret
- end
- def firstParty
- return nil if @party.length==0
- return @party[0]
- end
- def firstPokemon
- p=self.pokemonParty
- return nil if p.length==0
- return p[0]
- end
- def firstAblePokemon
- p=self.ablePokemonParty
- return nil if p.length==0
- return p[0]
- end
- def lastParty
- return nil if @party.length==0
- return @party[@party.length-1]
- end
- def lastPokemon
- p=self.pokemonParty
- return nil if p.length==0
- return p[p.length-1]
- end
- def lastAblePokemon
- p=self.ablePokemonParty
- return nil if p.length==0
- return p[p.length-1]
- end
- def pokedexSeen(region=-1) # Number of Pokémon seen
- ret=0
- if region==-1
- for i in 0..PBSpecies.maxValue
- ret+=1 if @seen[i]
- end
- else
- regionlist=pbAllRegionalSpecies(region)
- for i in regionlist
- ret+=1 if @seen[i]
- end
- end
- return ret
- end
- def pokedexOwned(region=-1) # Number of Pokémon owned
- ret=0
- if region==-1
- for i in 0..PBSpecies.maxValue
- ret+=1 if @owned[i]
- end
- else
- regionlist=pbAllRegionalSpecies(region)
- for i in regionlist
- ret+=1 if @owned[i]
- end
- end
- return ret
- end
- def numFormsSeen(species)
- ret=0
- array=@formseen[species]
- for i in 0...[array[0].length,array[1].length].max
- ret+=1 if array[0][i] || array[1][i]
- end
- return ret
- end
- def hasSeen?(species)
- if species.is_a?(String) || species.is_a?(Symbol)
- species=getID(PBSpecies,species)
- end
- return species>0 ? @seen[species] : false
- end
- def hasOwned?(species)
- if species.is_a?(String) || species.is_a?(Symbol)
- species=getID(PBSpecies,species)
- end
- return species>0 ? @owned[species] : false
- end
- def setSeen(species)
- if species.is_a?(String) || species.is_a?(Symbol)
- species=getID(PBSpecies,species)
- end
- @seen[species]=true if species>0
- end
- def setOwned(species)
- if species.is_a?(String) || species.is_a?(Symbol)
- species=getID(PBSpecies,species)
- end
- @owned[species]=true if species>0
- end
- def clearPokedex
- @seen=[]
- @owned=[]
- @formseen=[]
- @formlastseen=[]
- for i in 1..PBSpecies.maxValue
- @seen[i]=false
- @owned[i]=false
- @formlastseen[i]=[]
- @formseen[i]=[[],[]]
- end
- end
- def initialize(name,trainertype)
- @name=name
- @language=pbGetLanguage()
- @trainertype=trainertype
- @id=rand(256)
- @id|=rand(256)<<8
- @id|=rand(256)<<16
- @id|=rand(256)<<24
- @metaID=0
- @outfit=0
- @partyplus=0
- @pokegear=false
- @pokedex=false
- clearPokedex
- @shadowcaught=[]
- for i in 1..PBSpecies.maxValue
- @shadowcaught[i]=false
- end
- @badges=[]
- for i in 0...8
- @badges[i]=false
- end
- @money=INITIALMONEY
- @party=[]
- end
- end
- ################################################################################
- # Main battle class.
- ################################################################################
- class PokeBattle_Battle
- attr_reader(:scene) # Scene object for this battle
- attr_accessor(:decision) # Decision: 0=undecided; 1=win; 2=loss; 3=escaped; 4=caught
- attr_accessor(:internalbattle) # Internal battle flag
- attr_accessor(:doublebattle) # Double battle flag
- attr_accessor(:cantescape) # True if player can't escape
- attr_accessor(:shiftStyle) # Shift/Set "battle style" option
- attr_accessor(:battlescene) # "Battle scene" option
- attr_accessor(:debug) # Debug flag
- attr_reader(:player) # Player trainer
- attr_reader(:opponent) # Opponent trainer
- attr_reader(:party1) # Player's Pokémon party
- attr_reader(:party2) # Foe's Pokémon party
- attr_reader(:party1order) # Order of Pokémon in the player's party
- attr_reader(:party2order) # Order of Pokémon in the opponent's party
- attr_accessor(:fullparty1) # True if player's party's max size is 6 instead of 3
- attr_accessor(:fullparty2) # True if opponent's party's max size is 6 instead of 3
- attr_reader(:battlers) # Currently active Pokémon
- attr_accessor(:items) # Items held by opponents
- attr_reader(:sides) # Effects common to each side of a battle
- attr_reader(:field) # Effects common to the whole of a battle
- attr_accessor(:environment) # Battle surroundings
- attr_accessor(:weather) # Current weather, custom methods should use pbWeather instead
- attr_accessor(:weatherduration) # Duration of current weather, or -1 if indefinite
- attr_reader(:switching) # True if during the switching phase of the round
- attr_reader(:futuresight) # True if Future Sight is hitting
- attr_reader(:struggle) # The Struggle move
- attr_accessor(:choices) # Choices made by each Pokémon this round
- attr_reader(:successStates) # Success states
- attr_accessor(:lastMoveUsed) # Last move used
- attr_accessor(:lastMoveUser) # Last move user
- attr_accessor(:megaEvolution) # Battle index of each trainer's Pokémon to Mega Evolve
- attr_accessor(:amuletcoin) # Whether Amulet Coin's effect applies
- attr_accessor(:extramoney) # Money gained in battle by using Pay Day
- attr_accessor(:doublemoney) # Whether Happy Hour's effect applies
- attr_accessor(:endspeech) # Speech by opponent when player wins
- attr_accessor(:endspeech2) # Speech by opponent when player wins
- attr_accessor(:endspeechwin) # Speech by opponent when opponent wins
- attr_accessor(:endspeechwin2) # Speech by opponent when opponent wins
- attr_accessor(:rules)
- attr_reader(:turncount)
- attr_accessor :controlPlayer
- include PokeBattle_BattleCommon
- MAXPARTYSIZE = 40
- class BattleAbortedException < Exception; end
- def pbAbort
- raise BattleAbortedException.new("Battle aborted")
- end
- def pbDebugUpdate
- end
- def pbRandom(x)
- return rand(x)
- end
- def pbAIRandom(x)
- return rand(x)
- end
- ################################################################################
- # Initialise battle class.
- ################################################################################
- def initialize(scene,p1,p2,player,opponent)
- if p1.length==0
- raise ArgumentError.new(_INTL("Party 1 has no Pokémon."))
- return
- end
- if p2.length==0
- raise ArgumentError.new(_INTL("Party 2 has no Pokémon."))
- return
- end
- if p2.length>2 && !opponent
- raise ArgumentError.new(_INTL("Wild battles with more than two Pokémon are not allowed."))
- return
- end
- @scene = scene
- @decision = 0
- @internalbattle = true
- @doublebattle = false
- @cantescape = false
- @shiftStyle = true
- @battlescene = true
- @debug = false
- @debugupdate = 0
- if opponent && player.is_a?(Array) && player.length==0
- player = player[0]
- end
- if opponent && opponent.is_a?(Array) && opponent.length==0
- opponent = opponent[0]
- end
- @player = player # PokeBattle_Trainer object
- @opponent = opponent # PokeBattle_Trainer object
- @party1 = p1
- @party2 = p2
- if $Trainer.partyplus==40
- @party1order = []
- for i in 0...80; @party1order.push(i); end
- elsif $Trainer.partyplus==35
- @party1order = []
- for i in 0...75; @party1order.push(i); end
- elsif $Trainer.partyplus==32
- @party1order = []
- for i in 0...72; @party1order.push(i); end
- elsif $Trainer.partyplus==30
- @party1order = []
- for i in 0...70; @party1order.push(i); end
- elsif $Trainer.partyplus==28
- @party1order = []
- for i in 0...68; @party1order.push(i); end
- elsif $Trainer.partyplus==25
- @party1order = []
- for i in 0...65; @party1order.push(i); end
- elsif $Trainer.partyplus==24
- @party1order = []
- for i in 0...64; @party1order.push(i); end
- elsif $Trainer.partyplus==21
- @party1order = []
- for i in 0...61; @party1order.push(i); end
- elsif $Trainer.partyplus==20
- @party1order = []
- for i in 0...60; @party1order.push(i); end
- elsif $Trainer.partyplus==18
- @party1order = []
- for i in 0...58; @party1order.push(i); end
- elsif $Trainer.partyplus==16
- @party1order = []
- for i in 0...56; @party1order.push(i); end
- elsif $Trainer.partyplus==15
- @party1order = []
- for i in 0...55; @party1order.push(i); end
- elsif $Trainer.partyplus==14
- @party1order = []
- for i in 0...54; @party1order.push(i); end
- elsif $Trainer.partyplus==12
- @party1order = []
- for i in 0...52; @party1order.push(i); end
- elsif $Trainer.partyplus==10
- @party1order = []
- for i in 0...50; @party1order.push(i); end
- elsif $Trainer.partyplus==9
- @party1order = []
- for i in 0...49; @party1order.push(i); end
- elsif $Trainer.partyplus==8
- @party1order = []
- for i in 0...48; @party1order.push(i); end
- elsif $Trainer.partyplus==5
- @party1order = []
- for i in 0...45; @party1order.push(i); end
- elsif $Trainer.partyplus==4
- @party1order = []
- for i in 0...44; @party1order.push(i); end
- elsif $Trainer.partyplus==3
- @party1order = []
- for i in 0...43; @party1order.push(i); end
- elsif $Trainer.partyplus==2
- @party1order = []
- for i in 0...42; @party1order.push(i); end
- elsif $Trainer.partyplus==1
- @party1order = []
- for i in 0...41; @party1order.push(i); end
- else
- @party1order = []
- for i in 0...46; @party1order.push(i); end
- end
- @party2order = []
- for i in 0...80; @party2order.push(i); end
- @fullparty1 = false
- @fullparty2 = false
- @battlers = []
- @items = nil
- @sides = [PokeBattle_ActiveSide.new, # Player's side
- PokeBattle_ActiveSide.new] # Foe's side
- @field = PokeBattle_ActiveField.new # Whole field (gravity/rooms)
- @environment = PBEnvironment::None # e.g. Tall grass, cave, still water
- @weather = 0
- @weatherduration = 0
- @switching = false
- @futuresight = false
- @choices = [ [0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1] ]
- @successStates = []
- for i in 0...4
- @successStates.push(PokeBattle_SuccessState.new)
- end
- @lastMoveUsed = -1
- @lastMoveUser = -1
- @nextPickupUse = 0
- @megaEvolution = []
- if @player.is_a?(Array)
- @megaEvolution[0]=[-1]*@player.length
- else
- @megaEvolution[0]=[-1]
- end
- if @opponent.is_a?(Array)
- @megaEvolution[1]=[-1]*@opponent.length
- else
- @megaEvolution[1]=[-1]
- end
- @amuletcoin = false
- @extramoney = 0
- @doublemoney = false
- @endspeech = ""
- @endspeech2 = ""
- @endspeechwin = ""
- @endspeechwin2 = ""
- @rules = {}
- @turncount = 0
- @peer = PokeBattle_BattlePeer.create()
- @priority = []
- @usepriority = false
- @snaggedpokemon = []
- @runCommand = 0
- if hasConst?(PBMoves,:STRUGGLE)
- @struggle = PokeBattle_Move.pbFromPBMove(self,PBMove.new(getConst(PBMoves,:STRUGGLE)))
- else
- @struggle = PokeBattle_Struggle.new(self,nil)
- end
- @struggle.pp = -1
- for i in 0...4
- battlers[i] = PokeBattle_Battler.new(self,i)
- end
- for i in @party1
- next if !i
- i.itemRecycle = 0
- i.itemInitial = i.item
- i.belch = false
- end
- for i in @party2
- next if !i
- i.itemRecycle = 0
- i.itemInitial = i.item
- i.belch = false
- end
- end
- ################################################################################
- # Info about battle.
- ################################################################################
- def pbDoubleBattleAllowed?
- return false if !@fullparty1 && @party1.length>MAXPARTYSIZE
- return false if !@fullparty2 && @party2.length>MAXPARTYSIZE
- _opponent=@opponent
- _player=@player
- # Wild battle
- if !_opponent
- if @party2.length==1
- return false
- elsif @party2.length==2
- return true
- else
- return false
- end
- # Trainer battle
- else
- if _opponent.is_a?(Array)
- if _opponent.length==1
- _opponent=_opponent[0]
- elsif _opponent.length!=2
- return false
- end
- end
- _player=_player
- if _player.is_a?(Array)
- if _player.length==1
- _player=_player[0]
- elsif _player.length!=2
- return false
- end
- end
- if _opponent.is_a?(Array)
- sendout1=pbFindNextUnfainted(@party2,0,pbSecondPartyBegin(1))
- sendout2=pbFindNextUnfainted(@party2,pbSecondPartyBegin(1))
- return false if sendout1<0 || sendout2<0
- else
- sendout1=pbFindNextUnfainted(@party2,0)
- sendout2=pbFindNextUnfainted(@party2,sendout1+1)
- return false if sendout1<0 || sendout2<0
- end
- end
- if _player.is_a?(Array)
- sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0))
- sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0))
- return false if sendout1<0 || sendout2<0
- else
- sendout1=pbFindNextUnfainted(@party1,0)
- sendout2=pbFindNextUnfainted(@party1,sendout1+1)
- return false if sendout1<0 || sendout2<0
- end
- return true
- end
- def pbWeather
- for i in 0...4
- if @battlers[i].hasWorkingAbility(:CLOUDNINE) ||
- @battlers[i].hasWorkingAbility(:AIRLOCK)
- return 0
- end
- end
- return @weather
- end
- ################################################################################
- # Get battler info.
- ################################################################################
- def pbIsOpposing?(index)
- return (index%2)==1
- end
- def pbOwnedByPlayer?(index)
- return false if pbIsOpposing?(index)
- return false if @player.is_a?(Array) && index==2
- return true
- end
- def pbIsDoubleBattler?(index)
- return (index>=2)
- end
- # Only used for Wish
- def pbThisEx(battlerindex,pokemonindex)
- party=pbParty(battlerindex)
- if pbIsOpposing?(battlerindex)
- if @opponent
- return _INTL("The foe {1}",party[pokemonindex].name)
- else
- return _INTL("The wild {1}",party[pokemonindex].name)
- end
- else
- return party[pokemonindex].name
- end
- end
- # Checks whether an item can be removed from a Pokémon.
- def pbIsUnlosableItem(pkmn,item)
- return true if pbIsMail?(item)
- return false if pkmn.effects[PBEffects::Transform]
- return true if pkmn.pokemon && pkmn.pokemon.getMegaForm(true)!=0 # Mega Stone
- if isConst?(pkmn.ability,PBAbilities,:MULTITYPE)
- plates=[:FISTPLATE,:SKYPLATE,:TOXICPLATE,:EARTHPLATE,:STONEPLATE,
- :INSECTPLATE,:SPOOKYPLATE,:IRONPLATE,:FLAMEPLATE,:SPLASHPLATE,
- :MEADOWPLATE,:ZAPPLATE,:MINDPLATE,:ICICLEPLATE,:DRACOPLATE,
- :DREADPLATE,:PIXIEPLATE]
- for i in plates
- return true if isConst?(item,PBItems,i)
- end
- end
- combos=[[:GIRATINA,:GRISEOUSORB],
- [:GENESECT,:BURNDRIVE],
- [:GENESECT,:CHILLDRIVE],
- [:GENESECT,:DOUSEDRIVE],
- [:GENESECT,:SHOCKDRIVE],
- # Primal Reversion stones
- [:KYOGRE,:BLUEORB],
- [:GROUDON,:REDORB]
- ]
- for i in combos
- if isConst?(pkmn.species,PBSpecies,i[0]) && isConst?(item,PBItems,i[1])
- return true
- end
- end
- return false
- end
- def pbCheckGlobalAbility(a)
- for i in 0...4 # in order from own first, opposing first, own second, opposing second
- if @battlers[i].hasWorkingAbility(a)
- return @battlers[i]
- end
- end
- return nil
- end
- def nextPickupUse
- @nextPickupUse+=1
- return @nextPickupUse
- end
- ################################################################################
- # Player-related info.
- ################################################################################
- def pbPlayer
- if @player.is_a?(Array)
- return @player[0]
- else
- return @player
- end
- end
- def pbGetOwnerItems(battlerIndex)
- return [] if !@items
- if pbIsOpposing?(battlerIndex)
- if @opponent.is_a?(Array)
- return (battlerIndex==1) ? @items[0] : @items[1]
- else
- return @items
- end
- else
- return []
- end
- end
- def pbSetSeen(pokemon)
- if pokemon && @internalbattle
- self.pbPlayer.seen[pokemon.species]=true
- pbSeenForm(pokemon)
- end
- end
- def pbGetMegaRingName(battlerIndex)
- if pbBelongsToPlayer?(battlerIndex)
- for i in MEGARINGS
- next if !hasConst?(PBItems,i)
- return PBItems.getName(getConst(PBItems,i)) if $PokemonBag.pbHasItem?(i)
- end
- end
- # Add your own Mega objects for particular NPC trainers here
- # if isConst?(pbGetOwner(battlerIndex).trainertype,PBTrainers,:BUGCATCHER)
- # return _INTL("Mega Net")
- # end
- return _INTL("Mega Ring")
- end
- def pbHasMegaRing?(battlerIndex)
- return true if !pbBelongsToPlayer?(battlerIndex)
- for i in MEGARINGS
- next if !hasConst?(PBItems,i)
- return true if $PokemonBag.pbHasItem?(i)
- end
- return false
- end
- ################################################################################
- # Get party info, manipulate parties.
- ################################################################################
- def pbPokemonCount(party)
- count=0
- for i in party
- next if !i
- count+=1 if i.hp>0 && !i.egg?
- end
- return count
- end
- def pbAllFainted?(party)
- pbPokemonCount(party)==0
- end
- def pbMaxLevel(party)
- lv=0
- for i in party
- next if !i
- lv=i.level if lv<i.level
- end
- return lv
- end
- def pbMaxLevelFromIndex(index)
- party=pbParty(index)
- owner=(pbIsOpposing?(index)) ? @opponent : @player
- maxlevel=0
- if owner.is_a?(Array)
- start=0
- limit=pbSecondPartyBegin(index)
- start=limit if pbIsDoubleBattler?(index)
- for i in start...start+limit
- next if !party[i]
- maxlevel=party[i].level if maxlevel<party[i].level
- end
- else
- for i in party
- next if !i
- maxlevel=i.level if maxlevel<i.level
- end
- end
- return maxlevel
- end
- def pbParty(index)
- return pbIsOpposing?(index) ? party2 : party1
- end
- def pbOpposingParty(index)
- return pbIsOpposing?(index) ? party1 : party2
- end
- def pbSecondPartyBegin(battlerIndex) #Modify Me if Double Battles are being weird
- if $Trainer.partyplus==40
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 40 : 20
- end
- elsif $Trainer.partyplus==35
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 35 : 35
- end
- elsif $Trainer.partyplus==32
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 32 : 16
- end
- elsif $Trainer.partyplus==30
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 30 : 15
- end
- elsif $Trainer.partyplus==28
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 28 : 14
- end
- elsif $Trainer.partyplus==25
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 25 : 25
- end
- elsif $Trainer.partyplus==24
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 24 : 12
- end
- elsif $Trainer.partyplus==21
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 21 : 21
- end
- elsif $Trainer.partyplus==20
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 20 : 10
- end
- elsif $Trainer.partyplus==18
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 18 : 9
- end
- elsif $Trainer.partyplus==16
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 16 : 8
- end
- elsif $Trainer.partyplus==15
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 15 : 15
- end
- elsif $Trainer.partyplus==14
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 14 : 7
- end
- elsif $Trainer.partyplus==12
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 12 : 6
- end
- elsif $Trainer.partyplus==10
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 10 : 5
- end
- elsif $Trainer.partyplus==9
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 9 : 9
- end
- elsif $Trainer.partyplus==8
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 8 : 4
- end
- elsif $Trainer.partyplus==5
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 5 : 5
- end
- elsif $Trainer.partyplus==4
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 4 : 2
- end
- elsif $Trainer.partyplus==3
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 3 : 3
- end
- elsif $Trainer.partyplus==2
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 2 : 2
- end
- elsif $Trainer.partyplus==1
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 40 : 20
- else
- return @fullparty1 ? 1 : 1
- end
- else
- if pbIsOpposing?(battlerIndex)
- return @fullparty2 ? 6 : 3
- else
- return @fullparty1 ? 6 : 3
- end
- end
- end
- def pbPartyLength(battlerIndex)
- if pbIsOpposing?(battlerIndex)
- return (@opponent.is_a?(Array)) ? pbSecondPartyBegin(battlerIndex) : MAXPARTYSIZE
- else
- return @player.is_a?(Array) ? pbSecondPartyBegin(battlerIndex) : MAXPARTYSIZE
- end
- end
- def pbFindNextUnfainted(party,start,finish=-1)
- finish=party.length if finish<0
- for i in start...finish
- next if !party[i]
- return i if party[i].hp>0 && !party[i].egg?
- end
- return -1
- end
- def pbGetLastPokeInTeam(index)
- party=pbParty(index)
- partyorder=(!pbIsOpposing?(index)) ? @party1order : @party2order
- plength=pbPartyLength(index)
- pstart=pbGetOwnerIndex(index)*plength
- lastpoke=-1
- for i in pstart...pstart+plength
- p=party[partyorder[i]]
- next if !p || p.egg? || p.hp<=0
- lastpoke=partyorder[i]
- end
- return lastpoke
- end
- def pbFindPlayerBattler(pkmnIndex)
- battler=nil
- for k in 0...4
- if !pbIsOpposing?(k) && @battlers[k].pokemonIndex==pkmnIndex
- battler=@battlers[k]
- break
- end
- end
- return battler
- end
- def pbIsOwner?(battlerIndex,partyIndex)
- secondParty=pbSecondPartyBegin(battlerIndex)
- if !pbIsOpposing?(battlerIndex)
- return true if !@player || !@player.is_a?(Array)
- return (battlerIndex==0) ? partyIndex<secondParty : partyIndex>=secondParty
- else
- return true if !@opponent || !@opponent.is_a?(Array)
- return (battlerIndex==1) ? partyIndex<secondParty : partyIndex>=secondParty
- end
- end
- def pbGetOwner(battlerIndex)
- if pbIsOpposing?(battlerIndex)
- if @opponent.is_a?(Array)
- return (battlerIndex==1) ? @opponent[0] : @opponent[1]
- else
- return @opponent
- end
- else
- if @player.is_a?(Array)
- return (battlerIndex==0) ? @player[0] : @player[1]
- else
- return @player
- end
- end
- end
- def pbGetOwnerPartner(battlerIndex)
- if pbIsOpposing?(battlerIndex)
- if @opponent.is_a?(Array)
- return (battlerIndex==1) ? @opponent[1] : @opponent[0]
- else
- return @opponent
- end
- else
- if @player.is_a?(Array)
- return (battlerIndex==0) ? @player[1] : @player[0]
- else
- return @player
- end
- end
- end
- def pbGetOwnerIndex(battlerIndex)
- if pbIsOpposing?(battlerIndex)
- return (@opponent.is_a?(Array)) ? ((battlerIndex==1) ? 0 : 1) : 0
- else
- return (@player.is_a?(Array)) ? ((battlerIndex==0) ? 0 : 1) : 0
- end
- end
- def pbBelongsToPlayer?(battlerIndex)
- if @player.is_a?(Array) && @player.length>1
- return battlerIndex==0
- else
- return (battlerIndex%2)==0
- end
- return false
- end
- def pbPartyGetOwner(battlerIndex,partyIndex)
- secondParty=pbSecondPartyBegin(battlerIndex)
- if !pbIsOpposing?(battlerIndex)
- return @player if !@player || !@player.is_a?(Array)
- return (partyIndex<secondParty) ? @player[0] : @player[1]
- else
- return @opponent if !@opponent || !@opponent.is_a?(Array)
- return (partyIndex<secondParty) ? @opponent[0] : @opponent[1]
- end
- end
- def pbAddToPlayerParty(pokemon)
- party=pbParty(0)
- for i in 0...party.length
- party[i]=pokemon if pbIsOwner?(0,i) && !party[i]
- end
- end
- def pbRemoveFromParty(battlerIndex,partyIndex)
- party=pbParty(battlerIndex)
- side=(pbIsOpposing?(battlerIndex)) ? @opponent : @player
- order=(pbIsOpposing?(battlerIndex)) ? @party2order : @party1order
- secondpartybegin=pbSecondPartyBegin(battlerIndex)
- party[partyIndex]=nil
- if !side || !side.is_a?(Array) # Wild or single opponent
- party.compact!
- for i in partyIndex...party.length+1
- for j in 0...4
- next if !@battlers[j]
- if pbGetOwner(j)==side && @battlers[j].pokemonIndex==i
- @battlers[j].pokemonIndex-=1
- break
- end
- end
- end
- for i in 0...order.length
- order[i]=(i==partyIndex) ? order.length-1 : order[i]-1
- end
- else
- if partyIndex<secondpartybegin-1
- for i in partyIndex...secondpartybegin
- if i>=secondpartybegin-1
- party[i]=nil
- else
- party[i]=party[i+1]
- end
- end
- for i in 0...order.length
- next if order[i]>=secondpartybegin
- order[i]=(i==partyIndex) ? secondpartybegin-1 : order[i]-1
- end
- else
- for i in partyIndex...secondpartybegin+pbPartyLength(battlerIndex)
- if i>=party.length-1
- party[i]=nil
- else
- party[i]=party[i+1]
- end
- end
- for i in 0...order.length
- next if order[i]<secondpartybegin
- order[i]=(i==partyIndex) ? secondpartybegin+pbPartyLength(battlerIndex)-1 : order[i]-1
- end
- end
- end
- end
- ################################################################################
- # Check whether actions can be taken.
- ################################################################################
- def pbCanShowCommands?(idxPokemon)
- thispkmn=@battlers[idxPokemon]
- return false if thispkmn.fainted?
- return false if thispkmn.effects[PBEffects::TwoTurnAttack]>0
- return false if thispkmn.effects[PBEffects::HyperBeam]>0
- return false if thispkmn.effects[PBEffects::Rollout]>0
- return false if thispkmn.effects[PBEffects::Outrage]>0
- return false if thispkmn.effects[PBEffects::Uproar]>0
- return false if thispkmn.effects[PBEffects::Bide]>0
- return true
- end
- ################################################################################
- # Attacking.
- ################################################################################
- def pbCanShowFightMenu?(idxPokemon)
- thispkmn=@battlers[idxPokemon]
- if !pbCanShowCommands?(idxPokemon)
- return false
- end
- # No moves that can be chosen
- if !pbCanChooseMove?(idxPokemon,0,false) &&
- !pbCanChooseMove?(idxPokemon,1,false) &&
- !pbCanChooseMove?(idxPokemon,2,false) &&
- !pbCanChooseMove?(idxPokemon,3,false)
- return false
- end
- # Encore
- return false if thispkmn.effects[PBEffects::Encore]>0
- return true
- end
- def pbCanChooseMove?(idxPokemon,idxMove,showMessages,sleeptalk=false)
- thispkmn=@battlers[idxPokemon]
- thismove=thispkmn.moves[idxMove]
- opp1=thispkmn.pbOpposing1
- opp2=thispkmn.pbOpposing2
- if !thismove || thismove.id==0
- return false
- end
- if thismove.pp<=0 && thismove.totalpp>0 && !sleeptalk
- if showMessages
- pbDisplayPaused(_INTL("There's no PP left for this move!"))
- end
- return false
- end
- if thispkmn.hasWorkingItem(:ASSAULTVEST) && thismove.pbIsStatus?
- if showMessages
- pbDisplayPaused(_INTL("The effects of the {1} prevent status moves from being used!",
- PBItems.getName(thispkmn.item)))
- end
- return false
- end
- if thispkmn.effects[PBEffects::ChoiceBand]>=0 &&
- (thispkmn.hasWorkingItem(:CHOICEBAND) ||
- thispkmn.hasWorkingItem(:CHOICESPECS) ||
- thispkmn.hasWorkingItem(:CHOICESCARF))
- hasmove=false
- for i in 0...4
- if thispkmn.moves[i].id==thispkmn.effects[PBEffects::ChoiceBand]
- hasmove=true; break
- end
- end
- if hasmove && thismove.id!=thispkmn.effects[PBEffects::ChoiceBand]
- if showMessages
- pbDisplayPaused(_INTL("{1} allows the use of only {2}!",
- PBItems.getName(thispkmn.item),
- PBMoves.getName(thispkmn.effects[PBEffects::ChoiceBand])))
- end
- return false
- end
- end
- if opp1.effects[PBEffects::Imprison]
- if thismove.id==opp1.moves[0].id ||
- thismove.id==opp1.moves[1].id ||
- thismove.id==opp1.moves[2].id ||
- thismove.id==opp1.moves[3].id
- if showMessages
- pbDisplayPaused(_INTL("{1} can't use the sealed {2}!",thispkmn.pbThis,thismove.name))
- end
- #PBDebug.log("[CanChoose][#{opp1.pbThis} has: #{opp1.moves[0].name}, #{opp1.moves[1].name},#{opp1.moves[2].name},#{opp1.moves[3].name}]")
- return false
- end
- end
- if opp2.effects[PBEffects::Imprison]
- if thismove.id==opp2.moves[0].id ||
- thismove.id==opp2.moves[1].id ||
- thismove.id==opp2.moves[2].id ||
- thismove.id==opp2.moves[3].id
- if showMessages
- pbDisplayPaused(_INTL("{1} can't use the sealed {2}!",thispkmn.pbThis,thismove.name))
- end
- #PBDebug.log("[CanChoose][#{opp2.pbThis} has: #{opp2.moves[0].name}, #{opp2.moves[1].name},#{opp2.moves[2].name},#{opp2.moves[3].name}]")
- return false
- end
- end
- if thispkmn.effects[PBEffects::Taunt]>0 && thismove.basedamage==0
- if showMessages
- pbDisplayPaused(_INTL("{1} can't use {2} after the taunt!",thispkmn.pbThis,thismove.name))
- end
- return false
- end
- if thispkmn.effects[PBEffects::Torment]
- if thismove.id==thispkmn.lastMoveUsed
- if showMessages
- pbDisplayPaused(_INTL("{1} can't use the same move twice in a row due to the torment!",thispkmn.pbThis))
- end
- return false
- end
- end
- if thismove.id==thispkmn.effects[PBEffects::DisableMove] && !sleeptalk
- if showMessages
- pbDisplayPaused(_INTL("{1}'s {2} is disabled!",thispkmn.pbThis,thismove.name))
- end
- return false
- end
- if thismove.function==0x158 && # Belch
- (!thispkmn.pokemon || !thispkmn.pokemon.belch)
- if showMessages
- pbDisplayPaused(_INTL("{1} hasn't eaten any held berry, so it can't possibly belch!",thispkmn.pbThis))
- end
- return false
- end
- if thispkmn.effects[PBEffects::Encore]>0 && idxMove!=thispkmn.effects[PBEffects::EncoreIndex]
- return false
- end
- return true
- end
- def pbAutoChooseMove(idxPokemon,showMessages=true)
- thispkmn=@battlers[idxPokemon]
- if thispkmn.fainted?
- @choices[idxPokemon][0]=0
- @choices[idxPokemon][1]=0
- @choices[idxPokemon][2]=nil
- return
- end
- if thispkmn.effects[PBEffects::Encore]>0 &&
- pbCanChooseMove?(idxPokemon,thispkmn.effects[PBEffects::EncoreIndex],false)
- PBDebug.log("[Auto choosing Encore move] #{thispkmn.moves[thispkmn.effects[PBEffects::EncoreIndex]].name}")
- @choices[idxPokemon][0]=1 # "Use move"
- @choices[idxPokemon][1]=thispkmn.effects[PBEffects::EncoreIndex] # Index of move
- @choices[idxPokemon][2]=thispkmn.moves[thispkmn.effects[PBEffects::EncoreIndex]]
- @choices[idxPokemon][3]=-1 # No target chosen yet
- if @doublebattle
- thismove=thispkmn.moves[thispkmn.effects[PBEffects::EncoreIndex]]
- target=thispkmn.pbTarget(thismove)
- if target==PBTargets::SingleNonUser
- target=@scene.pbChooseTarget(idxPokemon,target)
- pbRegisterTarget(idxPokemon,target) if target>=0
- elsif target==PBTargets::UserOrPartner
- target=@scene.pbChooseTarget(idxPokemon,target)
- pbRegisterTarget(idxPokemon,target) if target>=0 && (target&1)==(idxPokemon&1)
- end
- end
- else
- if !pbIsOpposing?(idxPokemon)
- pbDisplayPaused(_INTL("{1} has no moves left!",thispkmn.name)) if showMessages
- end
- @choices[idxPokemon][0]=1 # "Use move"
- @choices[idxPokemon][1]=-1 # Index of move to be used
- @choices[idxPokemon][2]=@struggle # Use Struggle
- @choices[idxPokemon][3]=-1 # No target chosen yet
- end
- end
- def pbRegisterMove(idxPokemon,idxMove,showMessages=true)
- thispkmn=@battlers[idxPokemon]
- thismove=thispkmn.moves[idxMove]
- return false if !pbCanChooseMove?(idxPokemon,idxMove,showMessages)
- @choices[idxPokemon][0]=1 # "Use move"
- @choices[idxPokemon][1]=idxMove # Index of move to be used
- @choices[idxPokemon][2]=thismove # PokeBattle_Move object of the move
- @choices[idxPokemon][3]=-1 # No target chosen yet
- return true
- end
- def pbChoseMove?(i,move)
- return false if @battlers[i].fainted?
- if @choices[i][0]==1 && @choices[i][1]>=0
- choice=@choices[i][1]
- return isConst?(@battlers[i].moves[choice].id,PBMoves,move)
- end
- return false
- end
- def pbChoseMoveFunctionCode?(i,code)
- return false if @battlers[i].fainted?
- if @choices[i][0]==1 && @choices[i][1]>=0
- choice=@choices[i][1]
- return @battlers[i].moves[choice].function==code
- end
- return false
- end
- def pbRegisterTarget(idxPokemon,idxTarget)
- @choices[idxPokemon][3]=idxTarget # Set target of move
- return true
- end
- def pbPriority(ignorequickclaw=false,log=false)
- return @priority if @usepriority # use stored priority if round isn't over yet
- @priority.clear
- speeds=[]
- priorities=[]
- quickclaw=[]; lagging=[]
- minpri=0; maxpri=0
- temp=[]
- # Calculate each Pokémon's speed
- for i in 0...4
- speeds[i]=@battlers[i].pbSpeed
- quickclaw[i]=false
- lagging[i]=false
- if !ignorequickclaw && @choices[i][0]==1 # Chose to use a move
- if !quickclaw[i] && @battlers[i].hasWorkingItem(:CUSTAPBERRY) &&
- !@battlers[i].pbOpposing1.hasWorkingAbility(:UNNERVE) &&
- !@battlers[i].pbOpposing2.hasWorkingAbility(:UNNERVE)
- if (@battlers[i].hasWorkingAbility(:GLUTTONY) && @battlers[i].hp<=(@battlers[i].totalhp/2).floor) ||
- @battlers[i].hp<=(@battlers[i].totalhp/4).floor
- pbCommonAnimation("UseItem",@battlers[i],nil)
- quickclaw[i]=true
- pbDisplayBrief(_INTL("{1}'s {2} let it move first!",
- @battlers[i].pbThis,PBItems.getName(@battlers[i].item)))
- @battlers[i].pbConsumeItem
- end
- end
- if !quickclaw[i] && @battlers[i].hasWorkingItem(:QUICKCLAW)
- if pbRandom(10)<2
- pbCommonAnimation("UseItem",@battlers[i],nil)
- quickclaw[i]=true
- pbDisplayBrief(_INTL("{1}'s {2} let it move first!",
- @battlers[i].pbThis,PBItems.getName(@battlers[i].item)))
- end
- end
- if !quickclaw[i] &&
- (@battlers[i].hasWorkingAbility(:STALL) ||
- @battlers[i].hasWorkingItem(:LAGGINGTAIL) ||
- @battlers[i].hasWorkingItem(:FULLINCENSE))
- lagging[i]=true
- end
- end
- end
- # Calculate each Pokémon's priority bracket, and get the min/max priorities
- for i in 0...4
- # Assume that doing something other than using a move is priority 0
- pri=0
- if @choices[i][0]==1 # Chose to use a move
- pri=@choices[i][2].priority
- pri+=1 if @battlers[i].hasWorkingAbility(:PRANKSTER) &&
- @choices[i][2].pbIsStatus?
- pri+=1 if @battlers[i].hasWorkingAbility(:GALEWINGS) &&
- isConst?(@choices[i][2].type,PBTypes,:FLYING)
- end
- priorities[i]=pri
- if i==0
- minpri=pri
- maxpri=pri
- else
- minpri=pri if minpri>pri
- maxpri=pri if maxpri<pri
- end
- end
- # Find and order all moves with the same priority
- curpri=maxpri
- loop do
- temp.clear
- for j in 0...4
- temp.push(j) if priorities[j]==curpri
- end
- # Sort by speed
- if temp.length==1
- @priority[@priority.length]=@battlers[temp[0]]
- elsif temp.length>1
- n=temp.length
- for m in 0...temp.length-1
- for i in 1...temp.length
- # For each pair of battlers, rank the second compared to the first
- # -1 means rank higher, 0 means rank equal, 1 means rank lower
- cmp=0
- if quickclaw[temp[i]]
- cmp=-1
- if quickclaw[temp[i-1]]
- if speeds[temp[i]]==speeds[temp[i-1]]
- cmp=0
- else
- cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : 1
- end
- end
- elsif quickclaw[temp[i-1]]
- cmp=1
- elsif lagging[temp[i]]
- cmp=1
- if lagging[temp[i-1]]
- if speeds[temp[i]]==speeds[temp[i-1]]
- cmp=0
- else
- cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? 1 : -1
- end
- end
- elsif lagging[temp[i-1]]
- cmp=-1
- elsif speeds[temp[i]]!=speeds[temp[i-1]]
- if @field.effects[PBEffects::TrickRoom]>0
- cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? 1 : -1
- else
- cmp=(speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : 1
- end
- end
- if cmp<0 || # Swap the pair according to the second battler's rank
- (cmp==0 && pbRandom(2)==0)
- swaptmp=temp[i]
- temp[i]=temp[i-1]
- temp[i-1]=swaptmp
- end
- end
- end
- # Battlers in this bracket are properly sorted, so add them to @priority
- for i in temp
- @priority[@priority.length]=@battlers[i]
- end
- end
- curpri-=1
- break if curpri<minpri
- end
- # Write the priority order to the debug log
- if log
- d="[Priority] "; comma=false
- for i in 0...4
- if @priority[i] && !@priority[i].fainted?
- d+=", " if comma
- d+="#{@priority[i].pbThis(comma)} (#{@priority[i].index})"; comma=true
- end
- end
- PBDebug.log(d)
- end
- @usepriority=true
- return @priority
- end
- ################################################################################
- # Switching Pokémon.
- ################################################################################
- def pbCanSwitchLax?(idxPokemon,pkmnidxTo,showMessages)
- if pkmnidxTo>=0
- party=pbParty(idxPokemon)
- return false if pkmnidxTo>=party.length
- return false if !party[pkmnidxTo]
- if party[pkmnidxTo].egg?
- pbDisplayPaused(_INTL("An Egg can't battle!")) if showMessages
- return false
- end
- if !pbIsOwner?(idxPokemon,pkmnidxTo)
- owner=pbPartyGetOwner(idxPokemon,pkmnidxTo)
- pbDisplayPaused(_INTL("You can't switch {1}'s Pokémon with one of yours!",owner.name)) if showMessages
- return false
- end
- if party[pkmnidxTo].hp<=0
- pbDisplayPaused(_INTL("{1} has no energy left to battle!",party[pkmnidxTo].name)) if showMessages
- return false
- end
- if @battlers[idxPokemon].pokemonIndex==pkmnidxTo ||
- @battlers[idxPokemon].pbPartner.pokemonIndex==pkmnidxTo
- pbDisplayPaused(_INTL("{1} is already in battle!",party[pkmnidxTo].name)) if showMessages
- return false
- end
- end
- return true
- end
- def pbCanSwitch?(idxPokemon,pkmnidxTo,showMessages,ignoremeanlook=false)
- thispkmn=@battlers[idxPokemon]
- # Multi-Turn Attacks/Mean Look
- return false if !pbCanSwitchLax?(idxPokemon,pkmnidxTo,showMessages)
- isOpposing=pbIsOpposing?(idxPokemon)
- party=pbParty(idxPokemon)
- for i in 0...4
- next if isOpposing!=pbIsOpposing?(i)
- if choices[i][0]==2 && choices[i][1]==pkmnidxTo
- pbDisplayPaused(_INTL("{1} has already been selected.",party[pkmnidxTo].name)) if showMessages
- return false
- end
- end
- return true if thispkmn.hasWorkingItem(:SHEDSHELL)
- return true if USENEWBATTLEMECHANICS && thispkmn.pbHasType?(:GHOST)
- if thispkmn.effects[PBEffects::MultiTurn]>0 ||
- (!ignoremeanlook && thispkmn.effects[PBEffects::MeanLook]>=0)
- pbDisplayPaused(_INTL("{1} can't be switched out!",thispkmn.pbThis)) if showMessages
- return false
- end
- if @field.effects[PBEffects::FairyLock]>0
- pbDisplayPaused(_INTL("{1} can't be switched out!",thispkmn.pbThis)) if showMessages
- return false
- end
- if thispkmn.effects[PBEffects::Ingrain]
- pbDisplayPaused(_INTL("{1} can't be switched out!",thispkmn.pbThis)) if showMessages
- return false
- end
- opp1=thispkmn.pbOpposing1
- opp2=thispkmn.pbOpposing2
- opp=nil
- if thispkmn.pbHasType?(:STEEL)
- opp=opp1 if opp1.hasWorkingAbility(:MAGNETPULL)
- opp=opp2 if opp2.hasWorkingAbility(:MAGNETPULL)
- end
- if !thispkmn.isAirborne?
- opp=opp1 if opp1.hasWorkingAbility(:ARENATRAP)
- opp=opp2 if opp2.hasWorkingAbility(:ARENATRAP)
- end
- if !thispkmn.hasWorkingAbility(:SHADOWTAG)
- opp=opp1 if opp1.hasWorkingAbility(:SHADOWTAG)
- opp=opp2 if opp2.hasWorkingAbility(:SHADOWTAG)
- end
- if opp
- abilityname=PBAbilities.getName(opp.ability)
- pbDisplayPaused(_INTL("{1}'s {2} prevents switching!",opp.pbThis,abilityname)) if showMessages
- return false
- end
- return true
- end
- def pbRegisterSwitch(idxPokemon,idxOther)
- return false if !pbCanSwitch?(idxPokemon,idxOther,false)
- @choices[idxPokemon][0]=2 # "Switch Pokémon"
- @choices[idxPokemon][1]=idxOther # Index of other Pokémon to switch with
- @choices[idxPokemon][2]=nil
- side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
- owner=pbGetOwnerIndex(idxPokemon)
- if @megaEvolution[side][owner]==idxPokemon
- @megaEvolution[side][owner]=-1
- end
- return true
- end
- def pbCanChooseNonActive?(index)
- party=pbParty(index)
- for i in 0...party.length
- return true if pbCanSwitchLax?(index,i,false)
- end
- return false
- end
- def pbSwitch(favorDraws=false)
- if !favorDraws
- return if @decision>0
- else
- return if @decision==5
- end
- pbJudge()
- return if @decision>0
- firstbattlerhp=@battlers[0].hp
- switched=[]
- for index in 0...4
- next if !@doublebattle && pbIsDoubleBattler?(index)
- next if @battlers[index] && !@battlers[index].fainted?
- next if !pbCanChooseNonActive?(index)
- if !pbOwnedByPlayer?(index)
- if !pbIsOpposing?(index) || (@opponent && pbIsOpposing?(index))
- newenemy=pbSwitchInBetween(index,false,false)
- newenemyname=newenemy
- if newenemy>=0 && isConst?(pbParty(index)[newenemy].ability,PBAbilities,:ILLUSION)
- newenemyname=pbGetLastPokeInTeam(index)
- end
- opponent=pbGetOwner(index)
- if !@doublebattle && firstbattlerhp>0 && @shiftStyle && @opponent &&
- @internalbattle && pbCanChooseNonActive?(0) && pbIsOpposing?(index) &&
- @battlers[0].effects[PBEffects::Outrage]==0
- pbDisplayPaused(_INTL("{1} is about to send in {2}.",opponent.fullname,pbParty(index)[newenemyname].name))
- if pbDisplayConfirm(_INTL("Will {1} change Pokémon?",self.pbPlayer.name))
- newpoke=pbSwitchPlayer(0,true,true)
- if newpoke>=0
- newpokename=newpoke
- if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
- newpokename=pbGetLastPokeInTeam(0)
- end
- pbDisplayBrief(_INTL("{1}, that's enough! Come back!",@battlers[0].name))
- pbRecallAndReplace(0,newpoke,newpokename)
- switched.push(0)
- end
- end
- end
- pbRecallAndReplace(index,newenemy,newenemyname,false,false)
- switched.push(index)
- end
- elsif @opponent
- newpoke=pbSwitchInBetween(index,true,false)
- newpokename=newpoke
- if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
- newpokename=pbGetLastPokeInTeam(index)
- end
- pbRecallAndReplace(index,newpoke,newpokename)
- switched.push(index)
- else
- switch=false
- if !pbDisplayConfirm(_INTL("Use next Pokémon?"))
- switch=(pbRun(index,true)<=0)
- else
- switch=true
- end
- if switch
- newpoke=pbSwitchInBetween(index,true,false)
- newpokename=newpoke
- if isConst?(@party1[newpoke].ability,PBAbilities,:ILLUSION)
- newpokename=pbGetLastPokeInTeam(index)
- end
- pbRecallAndReplace(index,newpoke,newpokename)
- switched.push(index)
- end
- end
- end
- if switched.length>0
- priority=pbPriority
- for i in priority
- i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
- end
- end
- end
- def pbSendOut(index,pokemon)
- pbSetSeen(pokemon)
- @peer.pbOnEnteringBattle(self,pokemon)
- if pbIsOpposing?(index)
- @scene.pbTrainerSendOut(index,pokemon)
- else
- @scene.pbSendOut(index,pokemon)
- end
- @scene.pbResetMoveIndex(index)
- end
- def pbReplace(index,newpoke,batonpass=false)
- party=pbParty(index)
- oldpoke=@battlers[index].pokemonIndex
- # Initialise the new Pokémon
- @battlers[index].pbInitialize(party[newpoke],newpoke,batonpass)
- # Reorder the party for this battle
- partyorder=(!pbIsOpposing?(index)) ? @party1order : @party2order
- bpo=-1; bpn=-1
- for i in 0...partyorder.length
- bpo=i if partyorder[i]==oldpoke
- bpn=i if partyorder[i]==newpoke
- end
- p=partyorder[bpo]; partyorder[bpo]=partyorder[bpn]; partyorder[bpn]=p
- # Send out the new Pokémon
- pbSendOut(index,party[newpoke])
- pbSetSeen(party[newpoke])
- end
- def pbRecallAndReplace(index,newpoke,newpokename=-1,batonpass=false,moldbreaker=false)
- @battlers[index].pbResetForm
- if !@battlers[index].fainted?
- @scene.pbRecall(index)
- end
- pbMessagesOnReplace(index,newpoke,newpokename)
- pbReplace(index,newpoke,batonpass)
- return pbOnActiveOne(@battlers[index],false,moldbreaker)
- end
- def pbMessagesOnReplace(index,newpoke,newpokename=-1)
- newpokename=newpoke if newpokename<0
- party=pbParty(index)
- if pbOwnedByPlayer?(index)
- # if !party[newpoke]
- # p [index,newpoke,party[newpoke],pbAllFainted?(party)]
- # PBDebug.log([index,newpoke,party[newpoke],"pbMOR"].inspect)
- # for i in 0...party.length
- # PBDebug.log([i,party[i].hp].inspect)
- # end
- # raise BattleAbortedException.new
- # end
- opposing=@battlers[index].pbOppositeOpposing
- if opposing.fainted? || opposing.hp==opposing.totalhp
- pbDisplayBrief(_INTL("Go! {1}!",party[newpokename].name))
- elsif opposing.hp>=(opposing.totalhp/2)
- pbDisplayBrief(_INTL("Do it! {1}!",party[newpokename].name))
- elsif opposing.hp>=(opposing.totalhp/4)
- pbDisplayBrief(_INTL("Go for it, {1}!",party[newpokename].name))
- else
- pbDisplayBrief(_INTL("Your opponent's weak!\nGet 'em, {1}!",party[newpokename].name))
- end
- PBDebug.log("[Send out Pokémon] Player sent out #{party[newpokename].name} in position #{index}")
- else
- # if !party[newpoke]
- # p [index,newpoke,party[newpoke],pbAllFainted?(party)]
- # PBDebug.log([index,newpoke,party[newpoke],"pbMOR"].inspect)
- # for i in 0...party.length
- # PBDebug.log([i,party[i].hp].inspect)
- # end
- # raise BattleAbortedException.new
- # end
- owner=pbGetOwner(index)
- pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",owner.fullname,party[newpokename].name))
- PBDebug.log("[Send out Pokémon] Opponent sent out #{party[newpokename].name} in position #{index}")
- end
- end
- def pbSwitchInBetween(index,lax,cancancel)
- if !pbOwnedByPlayer?(index)
- return @scene.pbChooseNewEnemy(index,pbParty(index))
- else
- return pbSwitchPlayer(index,lax,cancancel)
- end
- end
- def pbSwitchPlayer(index,lax,cancancel)
- if @debug
- return @scene.pbChooseNewEnemy(index,pbParty(index))
- else
- return @scene.pbSwitch(index,lax,cancancel)
- end
- end
- ################################################################################
- # Using an item.
- ################################################################################
- # Uses an item on a Pokémon in the player's party.
- def pbUseItemOnPokemon(item,pkmnIndex,userPkmn,scene)
- pokemon=@party1[pkmnIndex]
- battler=nil
- name=pbGetOwner(userPkmn.index).fullname
- name=pbGetOwner(userPkmn.index).name if pbBelongsToPlayer?(userPkmn.index)
- pbDisplayBrief(_INTL("{1} used the\r\n{2}.",name,PBItems.getName(item)))
- PBDebug.log("[Use item] Player used #{PBItems.getName(item)} on #{pokemon.name}")
- ret=false
- if pokemon.egg?
- pbDisplay(_INTL("But it had no effect!"))
- else
- for i in 0...4
- if !pbIsOpposing?(i) && @battlers[i].pokemonIndex==pkmnIndex
- battler=@battlers[i]
- end
- end
- ret=ItemHandlers.triggerBattleUseOnPokemon(item,pokemon,battler,scene)
- end
- if !ret && pbBelongsToPlayer?(userPkmn.index)
- if $PokemonBag.pbCanStore?(item)
- $PokemonBag.pbStoreItem(item)
- else
- raise _INTL("Couldn't return unused item to Bag somehow.")
- end
- end
- return ret
- end
- # Uses an item on an active Pokémon.
- def pbUseItemOnBattler(item,index,userPkmn,scene)
- PBDebug.log("[Use item] Player used #{PBItems.getName(item)} on #{@battlers[index].pbThis(true)}")
- ret=ItemHandlers.triggerBattleUseOnBattler(item,@battlers[index],scene)
- if !ret && pbBelongsToPlayer?(userPkmn.index)
- if $PokemonBag.pbCanStore?(item)
- $PokemonBag.pbStoreItem(item)
- else
- raise _INTL("Couldn't return unused item to Bag somehow.")
- end
- end
- return ret
- end
- def pbRegisterItem(idxPokemon,idxItem,idxTarget=nil)
- if idxTarget!=nil && idxTarget>=0
- for i in 0...4
- if !@battlers[i].pbIsOpposing?(idxPokemon) &&
- @battlers[i].pokemonIndex==idxTarget &&
- @battlers[i].effects[PBEffects::Embargo]>0
- pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",@battlers[i].pbThis(true)))
- if pbBelongsToPlayer?(@battlers[i].index)
- if $PokemonBag.pbCanStore?(idxItem)
- $PokemonBag.pbStoreItem(idxItem)
- else
- raise _INTL("Couldn't return unused item to Bag somehow.")
- end
- end
- return false
- end
- end
- end
- if ItemHandlers.hasUseInBattle(idxItem)
- if idxPokemon==0 # Player's first Pokémon
- if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
- # Using Poké Balls or Poké Doll only
- ItemHandlers.triggerUseInBattle(idxItem,@battlers[idxPokemon],self)
- if @doublebattle
- @battlers[idxPokemon].pbPartner.effects[PBEffects::SkipTurn]=true
- end
- else
- if $PokemonBag.pbCanStore?(idxItem)
- $PokemonBag.pbStoreItem(idxItem)
- else
- raise _INTL("Couldn't return unusable item to Bag somehow.")
- end
- return false
- end
- else
- if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
- pbDisplay(_INTL("It's impossible to aim without being focused!"))
- end
- return false
- end
- end
- @choices[idxPokemon][0]=3 # "Use an item"
- @choices[idxPokemon][1]=idxItem # ID of item to be used
- @choices[idxPokemon][2]=idxTarget # Index of Pokémon to use item on
- side=(pbIsOpposing?(idxPokemon)) ? 1 : 0
- owner=pbGetOwnerIndex(idxPokemon)
- if @megaEvolution[side][owner]==idxPokemon
- @megaEvolution[side][owner]=-1
- end
- return true
- end
- def pbEnemyUseItem(item,battler)
- return 0 if !@internalbattle
- items=pbGetOwnerItems(battler.index)
- return if !items
- opponent=pbGetOwner(battler.index)
- for i in 0...items.length
- if items[i]==item
- items.delete_at(i)
- break
- end
- end
- itemname=PBItems.getName(item)
- pbDisplayBrief(_INTL("{1} used the\r\n{2}!",opponent.fullname,itemname))
- PBDebug.log("[Use item] Opponent used #{itemname} on #{battler.pbThis(true)}")
- if isConst?(item,PBItems,:POTION)
- battler.pbRecoverHP(20,true)
- pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
- elsif isConst?(item,PBItems,:SUPERPOTION)
- battler.pbRecoverHP(50,true)
- pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
- elsif isConst?(item,PBItems,:HYPERPOTION)
- battler.pbRecoverHP(200,true)
- pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
- elsif isConst?(item,PBItems,:MAXPOTION)
- battler.pbRecoverHP(battler.totalhp-battler.hp,true)
- pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
- elsif isConst?(item,PBItems,:FULLRESTORE)
- fullhp=(battler.hp==battler.totalhp)
- battler.pbRecoverHP(battler.totalhp-battler.hp,true)
- battler.status=0; battler.statusCount=0
- battler.effects[PBEffects::Confusion]=0
- if fullhp
- pbDisplay(_INTL("{1} became healthy!",battler.pbThis))
- else
- pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
- end
- elsif isConst?(item,PBItems,:FULLHEAL)
- battler.status=0; battler.statusCount=0
- battler.effects[PBEffects::Confusion]=0
- pbDisplay(_INTL("{1} became healthy!",battler.pbThis))
- elsif isConst?(item,PBItems,:XATTACK)
- if battler.pbCanIncreaseStatStage?(PBStats::ATTACK,battler)
- battler.pbIncreaseStat(PBStats::ATTACK,1,battler,true)
- end
- elsif isConst?(item,PBItems,:XDEFEND)
- if battler.pbCanIncreaseStatStage?(PBStats::DEFENSE,battler)
- battler.pbIncreaseStat(PBStats::DEFENSE,1,battler,true)
- end
- elsif isConst?(item,PBItems,:XSPEED)
- if battler.pbCanIncreaseStatStage?(PBStats::SPEED,battler)
- battler.pbIncreaseStat(PBStats::SPEED,1,battler,true)
- end
- elsif isConst?(item,PBItems,:XSPECIAL)
- if battler.pbCanIncreaseStatStage?(PBStats::SPATK,battler)
- battler.pbIncreaseStat(PBStats::SPATK,1,battler,true)
- end
- elsif isConst?(item,PBItems,:XSPDEF)
- if battler.pbCanIncreaseStatStage?(PBStats::SPDEF,battler)
- battler.pbIncreaseStat(PBStats::SPDEF,1,battler,true)
- end
- elsif isConst?(item,PBItems,:XACCURACY)
- if battler.pbCanIncreaseStatStage?(PBStats::ACCURACY,battler)
- battler.pbIncreaseStat(PBStats::ACCURACY,1,battler,true)
- end
- end
- end
- ################################################################################
- # Fleeing from battle.
- ################################################################################
- def pbCanRun?(idxPokemon)
- return false if @opponent
- return false if @cantescape && !pbIsOpposing?(idxPokemon)
- thispkmn=@battlers[idxPokemon]
- return true if thispkmn.pbHasType?(:GHOST) && USENEWBATTLEMECHANICS
- return true if thispkmn.hasWorkingItem(:SMOKEBALL)
- return true if thispkmn.hasWorkingAbility(:RUNAWAY)
- return pbCanSwitch?(idxPokemon,-1,false)
- end
- def pbRun(idxPokemon,duringBattle=false)
- thispkmn=@battlers[idxPokemon]
- if pbIsOpposing?(idxPokemon)
- return 0 if @opponent
- @choices[i][0]=5 # run
- @choices[i][1]=0
- @choices[i][2]=nil
- return -1
- end
- if @opponent
- if $DEBUG && Input.press?(Input::CTRL)
- if pbDisplayConfirm(_INTL("Treat this battle as a win?"))
- @decision=1
- return 1
- elsif pbDisplayConfirm(_INTL("Treat this battle as a loss?"))
- @decision=2
- return 1
- end
- elsif @internalbattle
- pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!"))
- elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?"))
- pbSEPlay("Battle flee")
- pbDisplay(_INTL("{1} forfeited the match!",self.pbPlayer.name))
- @decision=3
- return 1
- end
- return 0
- end
- if $DEBUG && Input.press?(Input::CTRL)
- pbSEPlay("Battle flee")
- pbDisplayPaused(_INTL("Got away safely!"))
- @decision=3
- return 1
- end
- if @cantescape
- pbDisplayPaused(_INTL("Can't escape!"))
- return 0
- end
- if thispkmn.pbHasType?(:GHOST) && USENEWBATTLEMECHANICS
- pbSEPlay("Battle flee")
- pbDisplayPaused(_INTL("Got away safely!"))
- @decision=3
- return 1
- end
- if thispkmn.hasWorkingAbility(:RUNAWAY)
- pbSEPlay("Battle flee")
- if duringBattle
- pbDisplayPaused(_INTL("Got away safely!"))
- else
- pbDisplayPaused(_INTL("{1} escaped using Run Away!",thispkmn.pbThis))
- end
- @decision=3
- return 1
- end
- if thispkmn.hasWorkingItem(:SMOKEBALL)
- pbSEPlay("Battle flee")
- if duringBattle
- pbDisplayPaused(_INTL("Got away safely!"))
- else
- pbDisplayPaused(_INTL("{1} escaped using its {2}!",thispkmn.pbThis,PBItems.getName(thispkmn.item)))
- end
- @decision=3
- return 1
- end
- if !duringBattle && !pbCanSwitch?(idxPokemon,-1,false)
- pbDisplayPaused(_INTL("Can't escape!"))
- return 0
- end
- # Note: not pbSpeed, because using unmodified Speed
- speedPlayer=@battlers[idxPokemon].speed
- opposing=@battlers[idxPokemon].pbOppositeOpposing
- opposing=opposing.pbPartner if opposing.fainted?
- if !opposing.fainted?
- speedEnemy=opposing.speed
- if speedPlayer>speedEnemy
- rate=256
- else
- speedEnemy=1 if speedEnemy<=0
- rate=speedPlayer*128/speedEnemy
- rate+=@runCommand*30
- rate&=0xFF
- end
- else
- rate=256
- end
- ret=1
- if pbAIRandom(256)<rate
- pbSEPlay("Battle flee")
- pbDisplayPaused(_INTL("Got away safely!"))
- @decision=3
- else
- pbDisplayPaused(_INTL("Can't escape!"))
- ret=-1
- end
- @runCommand+=1 if !duringBattle
- return ret
- end
- ################################################################################
- # Mega Evolve battler.
- ################################################################################
- def pbCanMegaEvolve?(index)
- return false if $game_switches[NO_MEGA_EVOLUTION]
- return false if !@battlers[index].hasMega?
- return false if pbIsOpposing?(index) && !@opponent
- return true if $DEBUG && Input.press?(Input::CTRL)
- return false if !pbHasMegaRing?(index)
- side=(pbIsOpposing?(index)) ? 1 : 0
- owner=pbGetOwnerIndex(index)
- return false if @megaEvolution[side][owner]!=-1
- return false if @battlers[index].effects[PBEffects::SkyDrop]
- return true
- end
- def pbRegisterMegaEvolution(index)
- side=(pbIsOpposing?(index)) ? 1 : 0
- owner=pbGetOwnerIndex(index)
- @megaEvolution[side][owner]=index
- end
- def pbMegaEvolve(index)
- return if !@battlers[index] || !@battlers[index].pokemon
- return if !(@battlers[index].hasMega? rescue false)
- return if (@battlers[index].isMega? rescue true)
- ownername=pbGetOwner(index).fullname
- ownername=pbGetOwner(index).name if pbBelongsToPlayer?(index)
- case (@battlers[index].pokemon.megaMessage rescue 0)
- when 1 # Rayquaza
- pbDisplay(_INTL("{1}'s fervent wish has reached {2}!",ownername,@battlers[index].pbThis))
- else
- pbDisplay(_INTL("{1}'s {2} is reacting to {3}'s {4}!",
- @battlers[index].pbThis,PBItems.getName(@battlers[index].item),
- ownername,pbGetMegaRingName(index)))
- end
- pbCommonAnimation("MegaEvolution",@battlers[index],nil)
- @battlers[index].pokemon.makeMega
- @battlers[index].form=@battlers[index].pokemon.form
- @battlers[index].pbUpdate(true)
- @scene.pbChangePokemon(@battlers[index],@battlers[index].pokemon)
- pbCommonAnimation("MegaEvolution2",@battlers[index],nil)
- meganame=(@battlers[index].pokemon.megaName rescue nil)
- if !meganame || meganame==""
- meganame=_INTL("Mega {1}",PBSpecies.getName(@battlers[index].pokemon.species))
- end
- pbDisplay(_INTL("{1} has Mega Evolved into {2}!",@battlers[index].pbThis,meganame))
- PBDebug.log("[Mega Evolution] #{@battlers[index].pbThis} became #{meganame}")
- side=(pbIsOpposing?(index)) ? 1 : 0
- owner=pbGetOwnerIndex(index)
- @megaEvolution[side][owner]=-2
- end
- ################################################################################
- # Primal Revert battler.
- ################################################################################
- def pbPrimalReversion(index)
- return if !@battlers[index] || !@battlers[index].pokemon
- return if !(@battlers[index].hasPrimal? rescue false)
- return if (@battlers[index].isPrimal? rescue true)
- if isConst?(@battlers[index].pokemon.species,PBSpecies,:KYOGRE)
- pbCommonAnimation("PrimalKyogre",@battlers[index],nil)
- elsif isConst?(@battlers[index].pokemon.species,PBSpecies,:GROUDON)
- pbCommonAnimation("PrimalGroudon",@battlers[index],nil)
- end
- @battlers[index].pokemon.makePrimal
- @battlers[index].form=@battlers[index].pokemon.form
- @battlers[index].pbUpdate(true)
- @scene.pbChangePokemon(@battlers[index],@battlers[index].pokemon)
- if isConst?(@battlers[index].pokemon.species,PBSpecies,:KYOGRE)
- pbCommonAnimation("PrimalKyogre2",@battlers[index],nil)
- elsif isConst?(@battlers[index].pokemon.species,PBSpecies,:GROUDON)
- pbCommonAnimation("PrimalGroudon2",@battlers[index],nil)
- end
- pbDisplay(_INTL("{1}'s Primal Reversion!\nIt reverted to its primal form!",@battlers[index].pbThis))
- PBDebug.log("[Primal Reversion] #{@battlers[index].pbThis} Primal Reverted")
- end
- ################################################################################
- # Call battler.
- ################################################################################
- def pbCall(index)
- owner=pbGetOwner(index)
- pbDisplay(_INTL("{1} called {2}!",owner.name,@battlers[index].name))
- pbDisplay(_INTL("{1}!",@battlers[index].name))
- PBDebug.log("[Call to Pokémon] #{owner.name} called to #{@battlers[index].pbThis(true)}")
- if @battlers[index].isShadow?
- if @battlers[index].inHyperMode?
- @battlers[index].pokemon.hypermode=false
- @battlers[index].pokemon.adjustHeart(-300)
- pbDisplay(_INTL("{1} came to its senses from the Trainer's call!",@battlers[index].pbThis))
- else
- pbDisplay(_INTL("But nothing happened!"))
- end
- elsif @battlers[index].status!=PBStatuses::SLEEP &&
- @battlers[index].pbCanIncreaseStatStage?(PBStats::ACCURACY,@battlers[index])
- @battlers[index].pbIncreaseStat(PBStats::ACCURACY,1,@battlers[index],true)
- else
- pbDisplay(_INTL("But nothing happened!"))
- end
- end
- ################################################################################
- # Gaining Experience.
- ################################################################################
- def pbGainEXP
- return if !@internalbattle
- successbegin=true
- for i in 0...4 # Not ordered by priority
- if !@doublebattle && pbIsDoubleBattler?(i)
- @battlers[i].participants=[]
- next
- end
- if pbIsOpposing?(i) && @battlers[i].participants.length>0 &&
- (@battlers[i].fainted? || @battlers[i].captured)
- haveexpall=(hasConst?(PBItems,:EXPALL) && $PokemonBag.pbHasItem?(:EXPALL))
- # First count the number of participants
- partic=0
- expshare=0
- for j in @battlers[i].participants
- next if !@party1[j] || !pbIsOwner?(0,j)
- partic+=1 if @party1[j].hp>0 && !@party1[j].egg?
- end
- if !haveexpall
- for j in 0...@party1.length
- next if !@party1[j] || !pbIsOwner?(0,j)
- expshare+=1 if @party1[j].hp>0 && !@party1[j].egg? &&
- (isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
- isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE))
- end
- end
- # Now calculate EXP for the participants
- if partic>0 || expshare>0 || haveexpall
- if !@opponent && successbegin && pbAllFainted?(@party2)
- @scene.pbWildBattleSuccess
- successbegin=false
- end
- for j in 0...@party1.length
- next if !@party1[j] || !pbIsOwner?(0,j)
- next if @party1[j].hp<=0 || @party1[j].egg?
- haveexpshare=(isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
- isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE))
- next if !haveexpshare && !@battlers[i].participants.include?(j)
- pbGainExpOne(j,@battlers[i],partic,expshare,haveexpall)
- end
- if haveexpall
- showmessage=true
- for j in 0...@party1.length
- next if !@party1[j] || !pbIsOwner?(0,j)
- next if @party1[j].hp<=0 || @party1[j].egg?
- next if isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
- isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE)
- next if @battlers[i].participants.include?(j)
- pbDisplayPaused(_INTL("The rest of your team gained Exp. Points thanks to the {1}!",
- PBItems.getName(getConst(PBItems,:EXPALL)))) if showmessage
- showmessage=false
- pbGainExpOne(j,@battlers[i],partic,expshare,haveexpall,false)
- end
- end
- end
- # Now clear the participants array
- @battlers[i].participants=[]
- end
- end
- end
- def pbGainExpOne(index,defeated,partic,expshare,haveexpall,showmessages=true)
- thispoke=@party1[index]
- # Original species, not current species
- level=defeated.level
- baseexp=defeated.pokemon.baseExp
- evyield=defeated.pokemon.evYield
- # Gain effort value points, using RS effort values
- totalev=0
- for k in 0...6
- totalev+=thispoke.ev[k]
- end
- for k in 0...6
- evgain=evyield[k]
- evgain*=2 if isConst?(thispoke.item,PBItems,:MACHOBRACE) ||
- isConst?(thispoke.itemInitial,PBItems,:MACHOBRACE)
- case k
- when PBStats::HP
- evgain+=4 if isConst?(thispoke.item,PBItems,:POWERWEIGHT) ||
- isConst?(thispoke.itemInitial,PBItems,:POWERWEIGHT)
- when PBStats::ATTACK
- evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBRACER) ||
- isConst?(thispoke.itemInitial,PBItems,:POWERBRACER)
- when PBStats::DEFENSE
- evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBELT) ||
- isConst?(thispoke.itemInitial,PBItems,:POWERBELT)
- when PBStats::SPATK
- evgain+=4 if isConst?(thispoke.item,PBItems,:POWERLENS) ||
- isConst?(thispoke.itemInitial,PBItems,:POWERLENS)
- when PBStats::SPDEF
- evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBAND) ||
- isConst?(thispoke.itemInitial,PBItems,:POWERBAND)
- when PBStats::SPEED
- evgain+=4 if isConst?(thispoke.item,PBItems,:POWERANKLET) ||
- isConst?(thispoke.itemInitial,PBItems,:POWERANKLET)
- end
- evgain*=2 if thispoke.pokerusStage>=1 # Infected or cured
- if evgain>0
- # Can't exceed overall limit
- evgain-=totalev+evgain-PokeBattle_Pokemon::EVLIMIT if totalev+evgain>PokeBattle_Pokemon::EVLIMIT
- # Can't exceed stat limit
- evgain-=thispoke.ev[k]+evgain-PokeBattle_Pokemon::EVSTATLIMIT if thispoke.ev[k]+evgain>PokeBattle_Pokemon::EVSTATLIMIT
- # Add EV gain
- thispoke.ev[k]+=evgain
- if thispoke.ev[k]>PokeBattle_Pokemon::EVSTATLIMIT
- print "Single-stat EV limit #{PokeBattle_Pokemon::EVSTATLIMIT} exceeded.\r\nStat: #{k} EV gain: #{evgain} EVs: #{thispoke.ev.inspect}"
- thispoke.ev[k]=PokeBattle_Pokemon::EVSTATLIMIT
- end
- totalev+=evgain
- if totalev>PokeBattle_Pokemon::EVLIMIT
- print "EV limit #{PokeBattle_Pokemon::EVLIMIT} exceeded.\r\nTotal EVs: #{totalev} EV gain: #{evgain} EVs: #{thispoke.ev.inspect}"
- end
- end
- end
- # Gain experience
- ispartic=0
- ispartic=1 if defeated.participants.include?(index)
- haveexpshare=(isConst?(thispoke.item,PBItems,:EXPSHARE) ||
- isConst?(thispoke.itemInitial,PBItems,:EXPSHARE)) ? 1 : 0
- exp=0
- if expshare>0
- if partic==0 # No participants, all Exp goes to Exp Share holders
- exp=(level*baseexp).floor
- exp=(exp/(NOSPLITEXP ? 1 : expshare)).floor*haveexpshare
- else
- if NOSPLITEXP
- exp=(level*baseexp).floor*ispartic
- exp=(level*baseexp/2).floor*haveexpshare if ispartic==0
- else
- exp=(level*baseexp/2).floor
- exp=(exp/partic).floor*ispartic + (exp/expshare).floor*haveexpshare
- end
- end
- elsif ispartic==1
- exp=(level*baseexp/(NOSPLITEXP ? 1 : partic)).floor
- elsif haveexpall
- exp=(level*baseexp/2).floor
- end
- return if exp<=0
- exp=(exp*3/2).floor if @opponent
- if USESCALEDEXPFORMULA
- exp=(exp/5).floor
- leveladjust=(2*level+10.0)/(level+thispoke.level+10.0)
- leveladjust=leveladjust**5
- leveladjust=Math.sqrt(leveladjust)
- exp=(exp*leveladjust).floor
- exp+=1 if ispartic>0 || haveexpshare>0
- else
- exp=(exp/7).floor
- end
- isOutsider=(thispoke.trainerID!=self.pbPlayer.id ||
- (thispoke.language!=0 && thispoke.language!=self.pbPlayer.language))
- if isOutsider
- if thispoke.language!=0 && thispoke.language!=self.pbPlayer.language
- exp=(exp*1.7).floor
- else
- exp=(exp*3/2).floor
- end
- end
- exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
- isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG)
- growthrate=thispoke.growthrate
- newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
- exp=newexp-thispoke.exp
- if exp>0
- if showmessages
- if isOutsider
- pbDisplayPaused(_INTL("{1} gained a boosted {2} Exp. Points!",thispoke.name,exp))
- else
- pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
- end
- end
- newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
- tempexp=0
- curlevel=thispoke.level
- if newlevel<curlevel
- debuginfo="#{thispoke.name}: #{thispoke.level}/#{newlevel} | #{thispoke.exp}/#{newexp} | gain: #{exp}"
- raise RuntimeError.new(_INTL("The new level ({1}) is less than the Pokémon's\r\ncurrent level ({2}), which shouldn't happen.\r\n[Debug: {3}]",
- newlevel,curlevel,debuginfo))
- return
- end
- if thispoke.respond_to?("isShadow?") && thispoke.isShadow?
- thispoke.exp+=exp
- else
- tempexp1=thispoke.exp
- tempexp2=0
- # Find battler
- battler=pbFindPlayerBattler(index)
- loop do
- # EXP Bar animation
- startexp=PBExperience.pbGetStartExperience(curlevel,growthrate)
- endexp=PBExperience.pbGetStartExperience(curlevel+1,growthrate)
- tempexp2=(endexp<newexp) ? endexp : newexp
- thispoke.exp=tempexp2
- @scene.pbEXPBar(thispoke,battler,startexp,endexp,tempexp1,tempexp2)
- tempexp1=tempexp2
- curlevel+=1
- if curlevel>newlevel
- thispoke.calcStats
- battler.pbUpdate(false) if battler
- @scene.pbRefresh
- break
- end
- oldtotalhp=thispoke.totalhp
- oldattack=thispoke.attack
- olddefense=thispoke.defense
- oldspeed=thispoke.speed
- oldspatk=thispoke.spatk
- oldspdef=thispoke.spdef
- if battler && battler.pokemon && @internalbattle
- battler.pokemon.changeHappiness("levelup")
- end
- thispoke.calcStats
- battler.pbUpdate(false) if battler
- @scene.pbRefresh
- pbDisplayPaused(_INTL("{1} grew to Level {2}!",thispoke.name,curlevel))
- @scene.pbLevelUp(thispoke,battler,oldtotalhp,oldattack,
- olddefense,oldspeed,oldspatk,oldspdef)
- # Finding all moves learned at this level
- movelist=thispoke.getMoveList
- for k in movelist
- if k[0]==thispoke.level # Learned a new move
- pbLearnMove(index,k[1])
- end
- end
- end
- end
- end
- end
- ################################################################################
- # Learning a move.
- ################################################################################
- def pbLearnMove(pkmnIndex,move)
- pokemon=@party1[pkmnIndex]
- return if !pokemon
- pkmnname=pokemon.name
- battler=pbFindPlayerBattler(pkmnIndex)
- movename=PBMoves.getName(move)
- for i in 0...4
- return if pokemon.moves[i].id==move
- if pokemon.moves[i].id==0
- pokemon.moves[i]=PBMove.new(move)
- battler.moves[i]=PokeBattle_Move.pbFromPBMove(self,pokemon.moves[i]) if battler
- pbDisplayPaused(_INTL("{1} learned {2}!",pkmnname,movename))
- PBDebug.log("[Learn move] #{pkmnname} learned #{movename}")
- return
- end
- end
- loop do
- pbDisplayPaused(_INTL("{1} is trying to learn {2}.",pkmnname,movename))
- pbDisplayPaused(_INTL("But {1} can't learn more than four moves.",pkmnname))
- if pbDisplayConfirm(_INTL("Delete a move to make room for {1}?",movename))
- pbDisplayPaused(_INTL("Which move should be forgotten?"))
- forgetmove=@scene.pbForgetMove(pokemon,move)
- if forgetmove>=0
- oldmovename=PBMoves.getName(pokemon.moves[forgetmove].id)
- pokemon.moves[forgetmove]=PBMove.new(move) # Replaces current/total PP
- battler.moves[forgetmove]=PokeBattle_Move.pbFromPBMove(self,pokemon.moves[forgetmove]) if battler
- pbDisplayPaused(_INTL("1, 2, and... ... ..."))
- pbDisplayPaused(_INTL("Poof!"))
- pbDisplayPaused(_INTL("{1} forgot {2}.",pkmnname,oldmovename))
- pbDisplayPaused(_INTL("And..."))
- pbDisplayPaused(_INTL("{1} learned {2}!",pkmnname,movename))
- PBDebug.log("[Learn move] #{pkmnname} forgot #{oldmovename} and learned #{movename}")
- return
- elsif pbDisplayConfirm(_INTL("Should {1} stop learning {2}?",pkmnname,movename))
- pbDisplayPaused(_INTL("{1} did not learn {2}.",pkmnname,movename))
- return
- end
- elsif pbDisplayConfirm(_INTL("Should {1} stop learning {2}?",pkmnname,movename))
- pbDisplayPaused(_INTL("{1} did not learn {2}.",pkmnname,movename))
- return
- end
- end
- end
- ################################################################################
- # Abilities.
- ################################################################################
- def pbOnActiveAll
- for i in 0...4 # Currently unfainted participants will earn EXP even if they faint afterwards
- @battlers[i].pbUpdateParticipants if pbIsOpposing?(i)
- @amuletcoin=true if !pbIsOpposing?(i) &&
- (isConst?(@battlers[i].item,PBItems,:AMULETCOIN) ||
- isConst?(@battlers[i].item,PBItems,:LUCKINCENSE))
- end
- for i in 0...4
- if !@battlers[i].fainted?
- if @battlers[i].isShadow? && pbIsOpposing?(i)
- pbCommonAnimation("Shadow",@battlers[i],nil)
- pbDisplay(_INTL("Oh!\nA Shadow Pokémon!"))
- end
- end
- end
- # Weather-inducing abilities, Trace, Imposter, etc.
- @usepriority=false
- priority=pbPriority
- for i in priority
- i.pbAbilitiesOnSwitchIn(true)
- end
- # Check forms are correct
- for i in 0...4
- next if @battlers[i].fainted?
- @battlers[i].pbCheckForm
- end
- end
- def pbOnActiveOne(pkmn,onlyabilities=false,moldbreaker=false)
- return false if pkmn.fainted?
- if !onlyabilities
- for i in 0...4 # Currently unfainted participants will earn EXP even if they faint afterwards
- @battlers[i].pbUpdateParticipants if pbIsOpposing?(i)
- @amuletcoin=true if !pbIsOpposing?(i) &&
- (isConst?(@battlers[i].item,PBItems,:AMULETCOIN) ||
- isConst?(@battlers[i].item,PBItems,:LUCKINCENSE))
- end
- if pkmn.isShadow? && pbIsOpposing?(pkmn.index)
- pbCommonAnimation("Shadow",pkmn,nil)
- pbDisplay(_INTL("Oh!\nA Shadow Pokémon!"))
- end
- # Healing Wish
- if pkmn.effects[PBEffects::HealingWish]
- PBDebug.log("[Lingering effect triggered] #{pkmn.pbThis}'s Healing Wish")
- pbCommonAnimation("HealingWish",pkmn,nil)
- pbDisplayPaused(_INTL("The healing wish came true for {1}!",pkmn.pbThis(true)))
- pkmn.pbRecoverHP(pkmn.totalhp,true)
- pkmn.pbCureStatus(false)
- pkmn.effects[PBEffects::HealingWish]=false
- end
- # Lunar Dance
- if pkmn.effects[PBEffects::LunarDance]
- PBDebug.log("[Lingering effect triggered] #{pkmn.pbThis}'s Lunar Dance")
- pbCommonAnimation("LunarDance",pkmn,nil)
- pbDisplayPaused(_INTL("{1} became cloaked in mystical moonlight!",pkmn.pbThis))
- pkmn.pbRecoverHP(pkmn.totalhp,true)
- pkmn.pbCureStatus(false)
- for i in 0...4
- pkmn.moves[i].pp=pkmn.moves[i].totalpp
- end
- pkmn.effects[PBEffects::LunarDance]=false
- end
- # Spikes
- if pkmn.pbOwnSide.effects[PBEffects::Spikes]>0 && !pkmn.isAirborne?(moldbreaker)
- if !pkmn.hasWorkingAbility(:MAGICGUARD)
- PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Spikes")
- spikesdiv=[8,6,4][pkmn.pbOwnSide.effects[PBEffects::Spikes]-1]
- @scene.pbDamageAnimation(pkmn,0)
- pkmn.pbReduceHP((pkmn.totalhp/spikesdiv).floor)
- pbDisplayPaused(_INTL("{1} is hurt by the spikes!",pkmn.pbThis))
- end
- end
- pkmn.pbFaint if pkmn.fainted?
- # Stealth Rock
- if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
- if !pkmn.hasWorkingAbility(:MAGICGUARD)
- atype=getConst(PBTypes,:ROCK) || 0
- eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
- if eff>0
- PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
- @scene.pbDamageAnimation(pkmn,0)
- pkmn.pbReduceHP(((pkmn.totalhp*eff)/64).floor)
- pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
- end
- end
- end
- pkmn.pbFaint if pkmn.fainted?
- # Toxic Spikes
- if pkmn.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 && !pkmn.fainted?
- if !pkmn.isAirborne?(moldbreaker)
- if pkmn.pbHasType?(:POISON)
- PBDebug.log("[Entry hazard] #{pkmn.pbThis} absorbed Toxic Spikes")
- pkmn.pbOwnSide.effects[PBEffects::ToxicSpikes]=0
- pbDisplayPaused(_INTL("{1} absorbed the poison spikes!",pkmn.pbThis))
- elsif pkmn.pbCanPoisonSpikes?(moldbreaker)
- PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Toxic Spikes")
- if pkmn.pbOwnSide.effects[PBEffects::ToxicSpikes]==2
- pkmn.pbPoison(nil,_INTL("{1} was badly poisoned by the poison spikes!",pkmn.pbThis,true))
- else
- pkmn.pbPoison(nil,_INTL("{1} was poisoned by the poison spikes!",pkmn.pbThis))
- end
- end
- end
- end
- # Sticky Web
- if pkmn.pbOwnSide.effects[PBEffects::StickyWeb] && !pkmn.fainted? &&
- !pkmn.isAirborne?(moldbreaker)
- if pkmn.pbCanReduceStatStage?(PBStats::SPEED,nil,false,nil,moldbreaker)
- PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Sticky Web")
- pkmn.pbReduceStat(PBStats::SPEED,1,nil,false,nil,true,moldbreaker)
- pbDisplayPaused(_INTL("{1} was caught in a sticky web!",pkmn.pbThis))
- end
- end
- end
- pkmn.pbAbilityCureCheck
- if pkmn.fainted?
- pbGainEXP
- pbJudge # pbSwitch
- return false
- end
- # pkmn.pbAbilitiesOnSwitchIn(true)
- if !onlyabilities
- pkmn.pbCheckForm
- pkmn.pbBerryCureCheck
- end
- return true
- end
- def pbPrimordialWeather
- # End Primordial Sea, Desolate Land, Delta Stream
- hasabil=false
- case @weather
- when PBWeather::HEAVYRAIN
- for i in 0...4
- if isConst?(@battlers[i].ability,PBAbilities,:PRIMORDIALSEA) &&
- !@battlers[i].fainted?
- hasabil=true; break
- end
- if !hasabil
- @weather=0
- pbDisplayBrief("The heavy rain has lifted!")
- end
- end
- when PBWeather::HARSHSUN
- for i in 0...4
- if isConst?(@battlers[i].ability,PBAbilities,:DESOLATELAND) &&
- !@battlers[i].fainted?
- hasabil=true; break
- end
- if !hasabil
- @weather=0
- pbDisplayBrief("The harsh sunlight faded!")
- end
- end
- when PBWeather::STRONGWINDS
- for i in 0...4
- if isConst?(@battlers[i].ability,PBAbilities,:DELTASTREAM) &&
- !@battlers[i].fainted?
- hasabil=true; break
- end
- if !hasabil
- @weather=0
- pbDisplayBrief("The mysterious air current has dissipated!")
- end
- end
- end
- end
- ################################################################################
- # Judging.
- ################################################################################
- def pbJudgeCheckpoint(attacker,move=0)
- end
- def pbDecisionOnTime
- count1=0
- count2=0
- hptotal1=0
- hptotal2=0
- for i in @party1
- next if !i
- if i.hp>0 && !i.egg?
- count1+=1
- hptotal1+=i.hp
- end
- end
- for i in @party2
- next if !i
- if i.hp>0 && !i.egg?
- count2+=1
- hptotal2+=i.hp
- end
- end
- return 1 if count1>count2 # win
- return 2 if count1<count2 # loss
- return 1 if hptotal1>hptotal2 # win
- return 2 if hptotal1<hptotal2 # loss
- return 5 # draw
- end
- def pbDecisionOnTime2
- count1=0
- count2=0
- hptotal1=0
- hptotal2=0
- for i in @party1
- next if !i
- if i.hp>0 && !i.egg?
- count1+=1
- hptotal1+=(i.hp*100/i.totalhp)
- end
- end
- hptotal1/=count1 if count1>0
- for i in @party2
- next if !i
- if i.hp>0 && !i.egg?
- count2+=1
- hptotal2+=(i.hp*100/i.totalhp)
- end
- end
- hptotal2/=count2 if count2>0
- return 1 if count1>count2 # win
- return 2 if count1<count2 # loss
- return 1 if hptotal1>hptotal2 # win
- return 2 if hptotal1<hptotal2 # loss
- return 5 # draw
- end
- def pbDecisionOnDraw
- return 5 # draw
- end
- def pbJudge
- # PBDebug.log("[Counts: #{pbPokemonCount(@party1)}/#{pbPokemonCount(@party2)}]")
- if pbAllFainted?(@party1) && pbAllFainted?(@party2)
- @decision=pbDecisionOnDraw() # Draw
- return
- end
- if pbAllFainted?(@party1)
- @decision=2 # Loss
- return
- end
- if pbAllFainted?(@party2)
- @decision=1 # Win
- return
- end
- end
- ################################################################################
- # Messages and animations.
- ################################################################################
- def pbDisplay(msg)
- @scene.pbDisplayMessage(msg)
- end
- def pbDisplayPaused(msg)
- @scene.pbDisplayPausedMessage(msg)
- end
- def pbDisplayBrief(msg)
- @scene.pbDisplayMessage(msg,true)
- end
- def pbDisplayConfirm(msg)
- @scene.pbDisplayConfirmMessage(msg)
- end
- def pbShowCommands(msg,commands,cancancel=true)
- @scene.pbShowCommands(msg,commands,cancancel)
- end
- def pbAnimation(move,attacker,opponent,hitnum=0)
- if @battlescene
- @scene.pbAnimation(move,attacker,opponent,hitnum)
- end
- end
- def pbCommonAnimation(name,attacker,opponent,hitnum=0)
- if @battlescene
- @scene.pbCommonAnimation(name,attacker,opponent,hitnum)
- end
- end
- ################################################################################
- # Battle core.
- ################################################################################
- def pbStartBattle(canlose=false)
- PBDebug.log("")
- PBDebug.log("******************************************")
- begin
- pbStartBattleCore(canlose)
- rescue BattleAbortedException
- @decision=0
- @scene.pbEndBattle(@decision)
- end
- return @decision
- end
- def pbStartBattleCore(canlose)
- if !@fullparty1 && @party1.length>MAXPARTYSIZE
- raise ArgumentError.new(_INTL("Party 1 has more than {1} Pokémon.",MAXPARTYSIZE))
- end
- if !@fullparty2 && @party2.length>MAXPARTYSIZE
- raise ArgumentError.new(_INTL("Party 2 has more than {1} Pokémon.",MAXPARTYSIZE))
- end
- #========================
- # Initialize wild Pokémon
- #========================
- if !@opponent
- if @party2.length==1
- if @doublebattle
- raise _INTL("Only two wild Pokémon are allowed in double battles")
- end
- wildpoke=@party2[0]
- @battlers[1].pbInitialize(wildpoke,0,false)
- @peer.pbOnEnteringBattle(self,wildpoke)
- pbSetSeen(wildpoke)
- @scene.pbStartBattle(self)
- pbDisplayPaused(_INTL("Wild {1} appeared!",wildpoke.name))
- elsif @party2.length==2
- if !@doublebattle
- raise _INTL("Only one wild Pokémon is allowed in single battles")
- end
- @battlers[1].pbInitialize(@party2[0],0,false)
- @battlers[3].pbInitialize(@party2[1],1,false)
- @peer.pbOnEnteringBattle(self,@party2[0])
- @peer.pbOnEnteringBattle(self,@party2[1])
- pbSetSeen(@party2[0])
- pbSetSeen(@party2[1])
- @scene.pbStartBattle(self)
- pbDisplayPaused(_INTL("Wild {1} and\r\n{2} appeared!",
- @party2[0].name,@party2[1].name))
- else
- raise _INTL("Only one or two wild Pokémon are allowed")
- end
- #=======================================
- # Initialize opponents in double battles
- #=======================================
- elsif @doublebattle
- if @opponent.is_a?(Array)
- if @opponent.length==1
- @opponent=@opponent[0]
- elsif @opponent.length!=2
- raise _INTL("Opponents with zero or more than two people are not allowed")
- end
- end
- if @player.is_a?(Array)
- if @player.length==1
- @player=@player[0]
- elsif @player.length!=2
- raise _INTL("Player trainers with zero or more than two people are not allowed")
- end
- end
- @scene.pbStartBattle(self)
- if @opponent.is_a?(Array)
- pbDisplayPaused(_INTL("{1} and {2} want to battle!",@opponent[0].fullname,@opponent[1].fullname))
- sendout1=pbFindNextUnfainted(@party2,0,pbSecondPartyBegin(1))
- raise _INTL("Opponent 1 has no unfainted Pokémon") if sendout1<0
- sendout2=pbFindNextUnfainted(@party2,pbSecondPartyBegin(1))
- raise _INTL("Opponent 2 has no unfainted Pokémon") if sendout2<0
- @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
- pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent[0].fullname,@battlers[1].name))
- pbSendOut(1,@party2[sendout1])
- @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
- pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent[1].fullname,@battlers[3].name))
- pbSendOut(3,@party2[sendout2])
- else
- pbDisplayPaused(_INTL("{1}\r\nwould like to battle!",@opponent.fullname))
- sendout1=pbFindNextUnfainted(@party2,0)
- sendout2=pbFindNextUnfainted(@party2,sendout1+1)
- if sendout1<0 || sendout2<0
- raise _INTL("Opponent doesn't have two unfainted Pokémon")
- end
- @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
- @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
- pbDisplayBrief(_INTL("{1} sent\r\nout {2} and {3}!",
- @opponent.fullname,@battlers[1].name,@battlers[3].name))
- pbSendOut(1,@party2[sendout1])
- pbSendOut(3,@party2[sendout2])
- end
- #======================================
- # Initialize opponent in single battles
- #======================================
- else
- sendout=pbFindNextUnfainted(@party2,0)
- raise _INTL("Trainer has no unfainted Pokémon") if sendout<0
- if @opponent.is_a?(Array)
- raise _INTL("Opponent trainer must be only one person in single battles") if @opponent.length!=1
- @opponent=@opponent[0]
- end
- if @player.is_a?(Array)
- raise _INTL("Player trainer must be only one person in single battles") if @player.length!=1
- @player=@player[0]
- end
- trainerpoke=@party2[sendout]
- @scene.pbStartBattle(self)
- pbDisplayPaused(_INTL("{1}\r\nwould like to battle!",@opponent.fullname))
- @battlers[1].pbInitialize(trainerpoke,sendout,false)
- pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent.fullname,@battlers[1].name))
- pbSendOut(1,trainerpoke)
- end
- #=====================================
- # Initialize players in double battles
- #=====================================
- if @doublebattle
- if @player.is_a?(Array)
- sendout1=pbFindNextUnfainted(@party1,0,pbSecondPartyBegin(0))
- raise _INTL("Player 1 has no unfainted Pokémon") if sendout1<0
- sendout2=pbFindNextUnfainted(@party1,pbSecondPartyBegin(0))
- raise _INTL("Player 2 has no unfainted Pokémon") if sendout2<0
- @battlers[0].pbInitialize(@party1[sendout1],sendout1,false)
- @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
- pbDisplayBrief(_INTL("{1} sent\r\nout {2}! Go! {3}!",
- @player[1].fullname,@battlers[2].name,@battlers[0].name))
- pbSetSeen(@party1[sendout1])
- pbSetSeen(@party1[sendout2])
- else
- sendout1=pbFindNextUnfainted(@party1,0)
- sendout2=pbFindNextUnfainted(@party1,sendout1+1)
- if sendout1<0 || sendout2<0
- raise _INTL("Player doesn't have two unfainted Pokémon")
- end
- @battlers[0].pbInitialize(@party1[sendout1],sendout1,false)
- @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
- pbDisplayBrief(_INTL("Go! {1} and {2}!",@battlers[0].name,@battlers[2].name))
- end
- pbSendOut(0,@party1[sendout1])
- pbSendOut(2,@party1[sendout2])
- #====================================
- # Initialize player in single battles
- #====================================
- else
- sendout=pbFindNextUnfainted(@party1,0)
- if sendout<0
- raise _INTL("Player has no unfainted Pokémon")
- end
- @battlers[0].pbInitialize(@party1[sendout],sendout,false)
- pbDisplayBrief(_INTL("Go! {1}!",@battlers[0].name))
- pbSendOut(0,@party1[sendout])
- end
- #==================
- # Initialize battle
- #==================
- if @weather==PBWeather::SUNNYDAY
- pbCommonAnimation("Sunny",nil,nil)
- pbDisplay(_INTL("The sunlight is strong."))
- elsif @weather==PBWeather::RAINDANCE
- pbCommonAnimation("Rain",nil,nil)
- pbDisplay(_INTL("It is raining."))
- elsif @weather==PBWeather::SANDSTORM
- pbCommonAnimation("Sandstorm",nil,nil)
- pbDisplay(_INTL("A sandstorm is raging."))
- elsif @weather==PBWeather::HAIL
- pbCommonAnimation("Hail",nil,nil)
- pbDisplay(_INTL("Hail is falling."))
- elsif @weather==PBWeather::HEAVYRAIN
- pbCommonAnimation("HeavyRain",nil,nil)
- pbDisplay(_INTL("It is raining heavily."))
- elsif @weather==PBWeather::HARSHSUN
- pbCommonAnimation("HarshSun",nil,nil)
- pbDisplay(_INTL("The sunlight is extremely harsh."))
- elsif @weather==PBWeather::STRONGWINDS
- pbCommonAnimation("StrongWinds",nil,nil)
- pbDisplay(_INTL("The wind is strong."))
- end
- pbOnActiveAll # Abilities
- @turncount=0
- loop do # Now begin the battle loop
- PBDebug.log("")
- PBDebug.log("***Round #{@turncount+1}***")
- if @debug && @turncount>=100
- @decision=pbDecisionOnTime()
- PBDebug.log("")
- PBDebug.log("***Undecided after 100 rounds, aborting***")
- pbAbort
- break
- end
- PBDebug.logonerr{
- pbCommandPhase
- }
- break if @decision>0
- PBDebug.logonerr{
- pbAttackPhase
- }
- break if @decision>0
- PBDebug.logonerr{
- pbEndOfRoundPhase
- }
- break if @decision>0
- @turncount+=1
- end
- return pbEndOfBattle(canlose)
- end
- ################################################################################
- # Command phase.
- ################################################################################
- def pbCommandMenu(i)
- return @scene.pbCommandMenu(i)
- end
- def pbItemMenu(i)
- return @scene.pbItemMenu(i)
- end
- def pbAutoFightMenu(i)
- return false
- end
- def pbCommandPhase
- @scene.pbBeginCommandPhase
- # @scene.pbResetCommandIndices
- for i in 0...4 # Reset choices if commands can be shown
- @battlers[i].effects[PBEffects::SkipTurn]=false
- if pbCanShowCommands?(i) || @battlers[i].fainted?
- @choices[i][0]=0
- @choices[i][1]=0
- @choices[i][2]=nil
- @choices[i][3]=-1
- else
- unless !@doublebattle && pbIsDoubleBattler?(i)
- PBDebug.log("[Reusing commands] #{@battlers[i].pbThis(true)}")
- end
- end
- end
- # Reset choices to perform Mega Evolution if it wasn't done somehow
- for i in 0...2
- for j in 0...@megaEvolution[i].length
- @megaEvolution[i][j]=-1 if @megaEvolution[i][j]>=0
- end
- end
- for i in 0...4
- break if @decision!=0
- next if @choices[i][0]!=0
- if !pbOwnedByPlayer?(i) || @controlPlayer
- if !@battlers[i].fainted? && pbCanShowCommands?(i)
- @scene.pbChooseEnemyCommand(i)
- end
- else
- commandDone=false
- commandEnd=false
- if pbCanShowCommands?(i)
- loop do
- cmd=pbCommandMenu(i)
- if cmd==0 # Fight
- if pbCanShowFightMenu?(i)
- commandDone=true if pbAutoFightMenu(i)
- until commandDone
- index=@scene.pbFightMenu(i)
- if index<0
- side=(pbIsOpposing?(i)) ? 1 : 0
- owner=pbGetOwnerIndex(i)
- if @megaEvolution[side][owner]==i
- @megaEvolution[side][owner]=-1
- end
- break
- end
- next if !pbRegisterMove(i,index)
- if @doublebattle
- thismove=@battlers[i].moves[index]
- target=@battlers[i].pbTarget(thismove)
- if target==PBTargets::SingleNonUser # single non-user
- target=@scene.pbChooseTarget(i,target)
- next if target<0
- pbRegisterTarget(i,target)
- elsif target==PBTargets::UserOrPartner # Acupressure
- target=@scene.pbChooseTarget(i,target)
- next if target<0 || (target&1)==1
- pbRegisterTarget(i,target)
- end
- end
- commandDone=true
- end
- else
- pbAutoChooseMove(i)
- commandDone=true
- end
- elsif cmd!=0 && @battlers[i].effects[PBEffects::SkyDrop]
- pbDisplay(_INTL("Sky Drop won't let {1} go!",@battlers[i].pbThis(true)))
- elsif cmd==1 # Bag
- if !@internalbattle
- if pbOwnedByPlayer?(i)
- pbDisplay(_INTL("Items can't be used here."))
- end
- else
- item=pbItemMenu(i)
- if item[0]>0
- if pbRegisterItem(i,item[0],item[1])
- commandDone=true
- end
- end
- end
- elsif cmd==2 # Pokémon
- pkmn=pbSwitchPlayer(i,false,true)
- if pkmn>=0
- commandDone=true if pbRegisterSwitch(i,pkmn)
- end
- elsif cmd==3 # Run
- run=pbRun(i)
- if run>0
- commandDone=true
- return
- elsif run<0
- commandDone=true
- side=(pbIsOpposing?(i)) ? 1 : 0
- owner=pbGetOwnerIndex(i)
- if @megaEvolution[side][owner]==i
- @megaEvolution[side][owner]=-1
- end
- end
- elsif cmd==4 # Call
- thispkmn=@battlers[i]
- @choices[i][0]=4 # "Call Pokémon"
- @choices[i][1]=0
- @choices[i][2]=nil
- side=(pbIsOpposing?(i)) ? 1 : 0
- owner=pbGetOwnerIndex(i)
- if @megaEvolution[side][owner]==i
- @megaEvolution[side][owner]=-1
- end
- commandDone=true
- elsif cmd==-1 # Go back to first battler's choice
- @megaEvolution[0][0]=-1 if @megaEvolution[0][0]>=0
- @megaEvolution[1][0]=-1 if @megaEvolution[1][0]>=0
- # Restore the item the player's first Pokémon was due to use
- if @choices[0][0]==3 && $PokemonBag && $PokemonBag.pbCanStore?(@choices[0][1])
- $PokemonBag.pbStoreItem(@choices[0][1])
- end
- pbCommandPhase
- return
- end
- break if commandDone
- end
- end
- end
- end
- end
- ################################################################################
- # Attack phase.
- ################################################################################
- def pbAttackPhase
- @scene.pbBeginAttackPhase
- for i in 0...4
- @successStates[i].clear
- if @choices[i][0]!=1 && @choices[i][0]!=2
- @battlers[i].effects[PBEffects::DestinyBond]=false
- @battlers[i].effects[PBEffects::Grudge]=false
- end
- @battlers[i].turncount+=1 if !@battlers[i].fainted?
- @battlers[i].effects[PBEffects::Rage]=false if !pbChoseMove?(i,:RAGE)
- end
- # Calculate priority at this time
- @usepriority=false
- priority=pbPriority(false,true)
- # Mega Evolution
- megaevolved=[]
- for i in priority
- if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
- side=(pbIsOpposing?(i.index)) ? 1 : 0
- owner=pbGetOwnerIndex(i.index)
- if @megaEvolution[side][owner]==i.index
- pbMegaEvolve(i.index)
- megaevolved.push(i.index)
- end
- end
- end
- if megaevolved.length>0
- for i in priority
- i.pbAbilitiesOnSwitchIn(true) if megaevolved.include?(i.index)
- end
- end
- # Call at Pokémon
- for i in priority
- if @choices[i.index][0]==4 && !i.effects[PBEffects::SkipTurn]
- pbCall(i.index)
- end
- end
- # Switch out Pokémon
- @switching=true
- switched=[]
- for i in priority
- if @choices[i.index][0]==2 && !i.effects[PBEffects::SkipTurn]
- index=@choices[i.index][1] # party position of Pokémon to switch to
- newpokename=index
- if isConst?(pbParty(i.index)[index].ability,PBAbilities,:ILLUSION)
- newpokename=pbGetLastPokeInTeam(i.index)
- end
- self.lastMoveUser=i.index
- if !pbOwnedByPlayer?(i.index)
- owner=pbGetOwner(i.index)
- pbDisplayBrief(_INTL("{1} withdrew {2}!",owner.fullname,i.name))
- PBDebug.log("[Withdrew Pokémon] Opponent withdrew #{i.pbThis(true)}")
- else
- pbDisplayBrief(_INTL("{1}, that's enough!\r\nCome back!",i.name))
- PBDebug.log("[Withdrew Pokémon] Player withdrew #{i.pbThis(true)}")
- end
- for j in priority
- next if !i.pbIsOpposing?(j.index)
- # if Pursuit and this target ("i") was chosen
- if pbChoseMoveFunctionCode?(j.index,0x88) && # Pursuit
- !j.hasMovedThisRound?
- if j.status!=PBStatuses::SLEEP && j.status!=PBStatuses::FROZEN &&
- !j.effects[PBEffects::SkyDrop] &&
- (!j.hasWorkingAbility(:TRUANT) || !j.effects[PBEffects::Truant])
- @choices[j.index][3]=i.index # Make sure to target the switching Pokémon
- j.pbUseMove(@choices[j.index]) # This calls pbGainEXP as appropriate
- j.effects[PBEffects::Pursuit]=true
- @switching=false
- return if @decision>0
- end
- end
- break if i.fainted?
- end
- if !pbRecallAndReplace(i.index,index,newpokename)
- # If a forced switch somehow occurs here in single battles
- # the attack phase now ends
- if !@doublebattle
- @switching=false
- return
- end
- else
- switched.push(i.index)
- end
- end
- end
- if switched.length>0
- for i in priority
- i.pbAbilitiesOnSwitchIn(true) if switched.include?(i.index)
- end
- end
- @switching=false
- # Use items
- for i in priority
- if @choices[i.index][0]==3 && !i.effects[PBEffects::SkipTurn]
- if pbIsOpposing?(i.index)
- # Opponent use item
- pbEnemyUseItem(@choices[i.index][1],i)
- else
- # Player use item
- item=@choices[i.index][1]
- if item>0
- usetype=$ItemData[item][ITEMBATTLEUSE]
- if usetype==1 || usetype==3
- if @choices[i.index][2]>=0
- pbUseItemOnPokemon(item,@choices[i.index][2],i,@scene)
- end
- elsif usetype==2 || usetype==4
- if !ItemHandlers.hasUseInBattle(item) # Poké Ball/Poké Doll used already
- pbUseItemOnBattler(item,@choices[i.index][2],i,@scene)
- end
- end
- end
- end
- end
- end
- # Use attacks
- for i in priority
- next if i.effects[PBEffects::SkipTurn]
- if pbChoseMoveFunctionCode?(i.index,0x115) # Focus Punch
- pbCommonAnimation("FocusPunch",i,nil)
- pbDisplay(_INTL("{1} is tightening its focus!",i.pbThis))
- end
- end
- 10.times do
- # Forced to go next
- advance=false
- for i in priority
- next if !i.effects[PBEffects::MoveNext]
- next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
- advance=i.pbProcessTurn(@choices[i.index])
- break if advance
- end
- return if @decision>0
- next if advance
- # Regular priority order
- for i in priority
- next if i.effects[PBEffects::Quash]
- next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
- advance=i.pbProcessTurn(@choices[i.index])
- break if advance
- end
- return if @decision>0
- next if advance
- # Quashed
- for i in priority
- next if !i.effects[PBEffects::Quash]
- next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
- advance=i.pbProcessTurn(@choices[i.index])
- break if advance
- end
- return if @decision>0
- next if advance
- # Check for all done
- for i in priority
- advance=true if @choices[i.index][0]==1 && !i.hasMovedThisRound? &&
- !i.effects[PBEffects::SkipTurn]
- break if advance
- end
- next if advance
- break
- end
- 10.times do
- @scene.pbGraphicsUpdate
- @scene.pbInputUpdate
- @scene.pbFrameUpdate
- end
- end
- ################################################################################
- # End of round.
- ################################################################################
- def pbEndOfRoundPhase
- PBDebug.log("[End of round]")
- for i in 0...4
- @battlers[i].effects[PBEffects::Electrify]=false
- @battlers[i].effects[PBEffects::Endure]=false
- @battlers[i].effects[PBEffects::FirstPledge]=0
- @battlers[i].effects[PBEffects::HyperBeam]-=1 if @battlers[i].effects[PBEffects::HyperBeam]>0
- @battlers[i].effects[PBEffects::KingsShield]=false
- @battlers[i].effects[PBEffects::LifeOrb]=false
- @battlers[i].effects[PBEffects::MoveNext]=false
- @battlers[i].effects[PBEffects::Powder]=false
- @battlers[i].effects[PBEffects::Protect]=false
- @battlers[i].effects[PBEffects::ProtectNegation]=false
- @battlers[i].effects[PBEffects::Quash]=false
- @battlers[i].effects[PBEffects::Roost]=false
- @battlers[i].effects[PBEffects::SpikyShield]=false
- end
- @usepriority=false # recalculate priority
- priority=pbPriority(true) # Ignoring Quick Claw here
- # Weather
- case @weather
- when PBWeather::SUNNYDAY
- @weatherduration=@weatherduration-1 if @weatherduration>0
- if @weatherduration==0
- pbDisplay(_INTL("The sunlight faded."))
- @weather=0
- PBDebug.log("[End of effect] Sunlight weather ended")
- else
- pbCommonAnimation("Sunny",nil,nil)
- # pbDisplay(_INTL("The sunlight is strong."))
- if pbWeather==PBWeather::SUNNYDAY
- for i in priority
- if i.hasWorkingAbility(:SOLARPOWER)
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Solar Power")
- @scene.pbDamageAnimation(i,0)
- i.pbReduceHP((i.totalhp/8).floor)
- pbDisplay(_INTL("{1} was hurt by the sunlight!",i.pbThis))
- if i.fainted?
- return if !i.pbFaint
- end
- end
- end
- end
- end
- when PBWeather::RAINDANCE
- @weatherduration=@weatherduration-1 if @weatherduration>0
- if @weatherduration==0
- pbDisplay(_INTL("The rain stopped."))
- @weather=0
- PBDebug.log("[End of effect] Rain weather ended")
- else
- pbCommonAnimation("Rain",nil,nil)
- # pbDisplay(_INTL("Rain continues to fall."))
- end
- when PBWeather::SANDSTORM
- @weatherduration=@weatherduration-1 if @weatherduration>0
- if @weatherduration==0
- pbDisplay(_INTL("The sandstorm subsided."))
- @weather=0
- PBDebug.log("[End of effect] Sandstorm weather ended")
- else
- pbCommonAnimation("Sandstorm",nil,nil)
- # pbDisplay(_INTL("The sandstorm rages."))
- if pbWeather==PBWeather::SANDSTORM
- PBDebug.log("[Lingering effect triggered] Sandstorm weather damage")
- for i in priority
- next if i.fainted?
- if !i.pbHasType?(:GROUND) && !i.pbHasType?(:ROCK) && !i.pbHasType?(:STEEL) &&
- !i.hasWorkingAbility(:SANDVEIL) &&
- !i.hasWorkingAbility(:SANDRUSH) &&
- !i.hasWorkingAbility(:SANDFORCE) &&
- !i.hasWorkingAbility(:MAGICGUARD) &&
- !i.hasWorkingAbility(:OVERCOAT) &&
- !i.hasWorkingItem(:SAFETYGOGGLES) &&
- ![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
- @scene.pbDamageAnimation(i,0)
- i.pbReduceHP((i.totalhp/16).floor)
- pbDisplay(_INTL("{1} is buffeted by the sandstorm!",i.pbThis))
- if i.fainted?
- return if !i.pbFaint
- end
- end
- end
- end
- end
- when PBWeather::HAIL
- @weatherduration=@weatherduration-1 if @weatherduration>0
- if @weatherduration==0
- pbDisplay(_INTL("The hail stopped."))
- @weather=0
- PBDebug.log("[End of effect] Hail weather ended")
- else
- pbCommonAnimation("Hail",nil,nil)
- # pbDisplay(_INTL("Hail continues to fall."))
- if pbWeather==PBWeather::HAIL
- PBDebug.log("[Lingering effect triggered] Hail weather damage")
- for i in priority
- next if i.fainted?
- if !i.pbHasType?(:ICE) &&
- !i.hasWorkingAbility(:ICEBODY) &&
- !i.hasWorkingAbility(:SNOWCLOAK) &&
- !i.hasWorkingAbility(:MAGICGUARD) &&
- !i.hasWorkingAbility(:OVERCOAT) &&
- !i.hasWorkingItem(:SAFETYGOGGLES) &&
- ![0xCA,0xCB].include?(PBMoveData.new(i.effects[PBEffects::TwoTurnAttack]).function) # Dig, Dive
- @scene.pbDamageAnimation(i,0)
- i.pbReduceHP((i.totalhp/16).floor)
- pbDisplay(_INTL("{1} is buffeted by the hail!",i.pbThis))
- if i.fainted?
- return if !i.pbFaint
- end
- end
- end
- end
- end
- when PBWeather::HEAVYRAIN
- hasabil=false
- for i in 0...4
- if isConst?(@battlers[i].ability,PBAbilities,:PRIMORDIALSEA) && !@battlers[i].fainted?
- hasabil=true; break
- end
- end
- @weatherduration=0 if !hasabil
- if @weatherduration==0
- pbDisplay(_INTL("The heavy rain stopped."))
- @weather=0
- PBDebug.log("[End of effect] Primordial Sea's rain weather ended")
- else
- pbCommonAnimation("HeavyRain",nil,nil)
- # pbDisplay(_INTL("It is raining heavily."))
- end
- when PBWeather::HARSHSUN
- hasabil=false
- for i in 0...4
- if isConst?(@battlers[i].ability,PBAbilities,:DESOLATELAND) && !@battlers[i].fainted?
- hasabil=true; break
- end
- end
- @weatherduration=0 if !hasabil
- if @weatherduration==0
- pbDisplay(_INTL("The harsh sunlight faded."))
- @weather=0
- PBDebug.log("[End of effect] Desolate Land's sunlight weather ended")
- else
- pbCommonAnimation("HarshSun",nil,nil)
- # pbDisplay(_INTL("The sunlight is extremely harsh."))
- if pbWeather==PBWeather::HARSHSUN
- for i in priority
- if i.hasWorkingAbility(:SOLARPOWER)
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Solar Power")
- @scene.pbDamageAnimation(i,0)
- i.pbReduceHP((i.totalhp/8).floor)
- pbDisplay(_INTL("{1} was hurt by the sunlight!",i.pbThis))
- if i.fainted?
- return if !i.pbFaint
- end
- end
- end
- end
- end
- when PBWeather::STRONGWINDS
- hasabil=false
- for i in 0...4
- if isConst?(@battlers[i].ability,PBAbilities,:DELTASTREAM) && !@battlers[i].fainted?
- hasabil=true; break
- end
- end
- @weatherduration=0 if !hasabil
- if @weatherduration==0
- pbDisplay(_INTL("The air current subsided."))
- @weather=0
- PBDebug.log("[End of effect] Delta Stream's wind weather ended")
- else
- pbCommonAnimation("StrongWinds",nil,nil)
- # pbDisplay(_INTL("The wind is strong."))
- end
- end
- # Shadow Sky weather
- if isConst?(@weather,PBWeather,:SHADOWSKY)
- @weatherduration=@weatherduration-1 if @weatherduration>0
- if @weatherduration==0
- pbDisplay(_INTL("The shadow sky faded."))
- @weather=0
- PBDebug.log("[End of effect] Shadow Sky weather ended")
- else
- pbCommonAnimation("ShadowSky",nil,nil)
- # pbDisplay(_INTL("The shadow sky continues."));
- if isConst?(pbWeather,PBWeather,:SHADOWSKY)
- PBDebug.log("[Lingering effect triggered] Shadow Sky weather damage")
- for i in priority
- next if i.fainted?
- if !i.isShadow?
- @scene.pbDamageAnimation(i,0)
- i.pbReduceHP((i.totalhp/16).floor)
- pbDisplay(_INTL("{1} was hurt by the shadow sky!",i.pbThis))
- if i.fainted?
- return if !i.pbFaint
- end
- end
- end
- end
- end
- end
- # Future Sight/Doom Desire
- for i in battlers # not priority
- next if i.fainted?
- if i.effects[PBEffects::FutureSight]>0
- i.effects[PBEffects::FutureSight]-=1
- if i.effects[PBEffects::FutureSight]==0
- move=i.effects[PBEffects::FutureSightMove]
- PBDebug.log("[Lingering effect triggered] #{PBMoves.getName(move)} struck #{i.pbThis(true)}")
- pbDisplay(_INTL("{1} took the {2} attack!",i.pbThis,PBMoves.getName(move)))
- moveuser=nil
- for j in battlers
- next if j.pbIsOpposing?(i.effects[PBEffects::FutureSightUserPos])
- if j.pokemonIndex==i.effects[PBEffects::FutureSightUser] && !j.fainted?
- moveuser=j; break
- end
- end
- if !moveuser
- party=pbParty(i.effects[PBEffects::FutureSightUserPos])
- if party[i.effects[PBEffects::FutureSightUser]].hp>0
- moveuser=PokeBattle_Battler.new(self,i.effects[PBEffects::FutureSightUserPos])
- moveuser.pbInitDummyPokemon(party[i.effects[PBEffects::FutureSightUser]],
- i.effects[PBEffects::FutureSightUser])
- end
- end
- if !moveuser
- pbDisplay(_INTL("But it failed!"))
- else
- @futuresight=true
- moveuser.pbUseMoveSimple(move,-1,i.index)
- @futuresight=false
- end
- i.effects[PBEffects::FutureSight]=0
- i.effects[PBEffects::FutureSightMove]=0
- i.effects[PBEffects::FutureSightUser]=-1
- i.effects[PBEffects::FutureSightUserPos]=-1
- if i.fainted?
- return if !i.pbFaint
- next
- end
- end
- end
- end
- for i in priority
- next if i.fainted?
- # Rain Dish
- if i.hasWorkingAbility(:RAINDISH) && i.effects[PBEffects::HealBlock]==0 &&
- (pbWeather==PBWeather::RAINDANCE ||
- pbWeather==PBWeather::HEAVYRAIN)
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Rain Dish")
- hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
- pbDisplay(_INTL("{1}'s {2} restored its HP a little!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
- end
- # Dry Skin
- if i.hasWorkingAbility(:DRYSKIN)
- if (pbWeather==PBWeather::RAINDANCE || pbWeather==PBWeather::HEAVYRAIN) &&
- i.effects[PBEffects::HealBlock]==0
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Dry Skin (in rain)")
- hpgain=i.pbRecoverHP((i.totalhp/8).floor,true)
- pbDisplay(_INTL("{1}'s {2} was healed by the rain!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
- elsif pbWeather==PBWeather::SUNNYDAY ||
- pbWeather==PBWeather::HARSHSUN
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Dry Skin (in sun)")
- @scene.pbDamageAnimation(i,0)
- hploss=i.pbReduceHP((i.totalhp/8).floor)
- pbDisplay(_INTL("{1}'s {2} was hurt by the sunlight!",i.pbThis,PBAbilities.getName(i.ability))) if hploss>0
- end
- end
- # Ice Body
- if i.hasWorkingAbility(:ICEBODY) && pbWeather==PBWeather::HAIL &&
- i.effects[PBEffects::HealBlock]==0
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Ice Body")
- hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
- pbDisplay(_INTL("{1}'s {2} restored its HP a little!",i.pbThis,PBAbilities.getName(i.ability))) if hpgain>0
- end
- if i.fainted?
- return if !i.pbFaint
- end
- end
- # Wish
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Wish]>0
- i.effects[PBEffects::Wish]-=1
- if i.effects[PBEffects::Wish]==0
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Wish")
- hpgain=i.pbRecoverHP(i.effects[PBEffects::WishAmount],true)
- if hpgain>0
- wishmaker=pbThisEx(i.index,i.effects[PBEffects::WishMaker])
- pbDisplay(_INTL("{1}'s wish came true!",wishmaker))
- end
- end
- end
- end
- # Fire Pledge + Grass Pledge combination damage
- for i in 0...2
- if sides[i].effects[PBEffects::SeaOfFire]>0 &&
- pbWeather!=PBWeather::RAINDANCE &&
- pbWeather!=PBWeather::HEAVYRAIN
- @battle.pbCommonAnimation("SeaOfFire",nil,nil) if i==0
- @battle.pbCommonAnimation("SeaOfFireOpp",nil,nil) if i==1
- for j in priority
- next if (j.index&1)!=i
- next if j.pbHasType?(:FIRE) || j.hasWorkingAbility(:MAGICGUARD)
- @scene.pbDamageAnimation(j,0)
- hploss=j.pbReduceHP((j.totalhp/8).floor)
- pbDisplay(_INTL("{1} is hurt by the sea of fire!",j.pbThis)) if hploss>0
- if j.fainted?
- return if !j.pbFaint
- end
- end
- end
- end
- for i in priority
- next if i.fainted?
- # Shed Skin, Hydration
- if (i.hasWorkingAbility(:SHEDSKIN) && pbRandom(10)<3) ||
- (i.hasWorkingAbility(:HYDRATION) && (pbWeather==PBWeather::RAINDANCE ||
- pbWeather==PBWeather::HEAVYRAIN))
- if i.status>0
- PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
- s=i.status
- i.pbCureStatus(false)
- case s
- when PBStatuses::SLEEP
- pbDisplay(_INTL("{1}'s {2} cured its sleep problem!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::POISON
- pbDisplay(_INTL("{1}'s {2} cured its poison problem!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::BURN
- pbDisplay(_INTL("{1}'s {2} healed its burn!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::PARALYSIS
- pbDisplay(_INTL("{1}'s {2} cured its paralysis!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::FROZEN
- pbDisplay(_INTL("{1}'s {2} thawed it out!",i.pbThis,PBAbilities.getName(i.ability)))
- end
- end
- end
- # Healer
- if i.hasWorkingAbility(:HEALER) && pbRandom(10)<3
- partner=i.pbPartner
- if partner && partner.status>0
- PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
- s=partner.status
- partner.pbCureStatus(false)
- case s
- when PBStatuses::SLEEP
- pbDisplay(_INTL("{1}'s {2} cured its partner's sleep problem!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::POISON
- pbDisplay(_INTL("{1}'s {2} cured its partner's poison problem!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::BURN
- pbDisplay(_INTL("{1}'s {2} healed its partner's burn!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::PARALYSIS
- pbDisplay(_INTL("{1}'s {2} cured its partner's paralysis!",i.pbThis,PBAbilities.getName(i.ability)))
- when PBStatuses::FROZEN
- pbDisplay(_INTL("{1}'s {2} thawed its partner out!",i.pbThis,PBAbilities.getName(i.ability)))
- end
- end
- end
- end
- for i in priority
- next if i.fainted?
- # Grassy Terrain (healing)
- if @field.effects[PBEffects::GrassyTerrain]>0 && !i.isAirborne?
- if i.effects[PBEffects::HealBlock]==0
- hpgain=i.pbRecoverHP((i.totalhp/16).floor,true)
- pbDisplay(_INTL("{1}'s HP was restored.",i.pbThis)) if hpgain>0
- end
- end
- # Held berries/Leftovers/Black Sludge
- i.pbBerryCureCheck(true)
- if i.fainted?
- return if !i.pbFaint
- end
- end
- # Aqua Ring
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::AquaRing]
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Aqua Ring")
- hpgain=(i.totalhp/16).floor
- hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT)
- hpgain=i.pbRecoverHP(hpgain,true)
- pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",i.pbThis)) if hpgain>0
- end
- end
- # Ingrain
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Ingrain]
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Ingrain")
- hpgain=(i.totalhp/16).floor
- hpgain=(hpgain*1.3).floor if i.hasWorkingItem(:BIGROOT)
- hpgain=i.pbRecoverHP(hpgain,true)
- pbDisplay(_INTL("{1} absorbed nutrients with its roots!",i.pbThis)) if hpgain>0
- end
- end
- # Leech Seed
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::LeechSeed]>=0 && !i.hasWorkingAbility(:MAGICGUARD)
- recipient=@battlers[i.effects[PBEffects::LeechSeed]]
- if recipient && !recipient.fainted?
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Leech Seed")
- pbCommonAnimation("LeechSeed",recipient,i)
- hploss=i.pbReduceHP((i.totalhp/8).floor,true)
- if i.hasWorkingAbility(:LIQUIDOOZE)
- recipient.pbReduceHP(hploss,true)
- pbDisplay(_INTL("{1} sucked up the liquid ooze!",recipient.pbThis))
- else
- if recipient.effects[PBEffects::HealBlock]==0
- hploss=(hploss*1.3).floor if recipient.hasWorkingItem(:BIGROOT)
- recipient.pbRecoverHP(hploss,true)
- end
- pbDisplay(_INTL("{1}'s health was sapped by Leech Seed!",i.pbThis))
- end
- if i.fainted?
- return if !i.pbFaint
- end
- if recipient.fainted?
- return if !recipient.pbFaint
- end
- end
- end
- end
- for i in priority
- next if i.fainted?
- # Poison/Bad poison
- if i.status==PBStatuses::POISON
- if i.statusCount>0
- i.effects[PBEffects::Toxic]+=1
- i.effects[PBEffects::Toxic]=[15,i.effects[PBEffects::Toxic]].min
- end
- if i.hasWorkingAbility(:POISONHEAL)
- pbCommonAnimation("Poison",i,nil)
- if i.effects[PBEffects::HealBlock]==0 && i.hp<i.totalhp
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Poison Heal")
- i.pbRecoverHP((i.totalhp/8).floor,true)
- pbDisplay(_INTL("{1} is healed by poison!",i.pbThis))
- end
- else
- if !i.hasWorkingAbility(:MAGICGUARD)
- PBDebug.log("[Status damage] #{i.pbThis} took damage from poison/toxic")
- if i.statusCount==0
- i.pbReduceHP((i.totalhp/8).floor)
- else
- i.pbReduceHP(((i.totalhp*i.effects[PBEffects::Toxic])/16).floor)
- end
- i.pbContinueStatus
- end
- end
- end
- # Burn
- if i.status==PBStatuses::BURN
- if !i.hasWorkingAbility(:MAGICGUARD)
- PBDebug.log("[Status damage] #{i.pbThis} took damage from burn")
- if i.hasWorkingAbility(:HEATPROOF)
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Heatproof")
- i.pbReduceHP((i.totalhp/16).floor)
- else
- i.pbReduceHP((i.totalhp/8).floor)
- end
- end
- i.pbContinueStatus
- end
- # Nightmare
- if i.effects[PBEffects::Nightmare]
- if i.status==PBStatuses::SLEEP
- if !i.hasWorkingAbility(:MAGICGUARD)
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s nightmare")
- i.pbReduceHP((i.totalhp/4).floor,true)
- pbDisplay(_INTL("{1} is locked in a nightmare!",i.pbThis))
- end
- else
- i.effects[PBEffects::Nightmare]=false
- end
- end
- if i.fainted?
- return if !i.pbFaint
- next
- end
- end
- # Curse
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Curse] && !i.hasWorkingAbility(:MAGICGUARD)
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s curse")
- i.pbReduceHP((i.totalhp/4).floor,true)
- pbDisplay(_INTL("{1} is afflicted by the curse!",i.pbThis))
- end
- if i.fainted?
- return if !i.pbFaint
- next
- end
- end
- # Multi-turn attacks (Bind/Clamp/Fire Spin/Magma Storm/Sand Tomb/Whirlpool/Wrap)
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::MultiTurn]>0
- i.effects[PBEffects::MultiTurn]-=1
- movename=PBMoves.getName(i.effects[PBEffects::MultiTurnAttack])
- if i.effects[PBEffects::MultiTurn]==0
- PBDebug.log("[End of effect] Trapping move #{movename} affecting #{i.pbThis} ended")
- pbDisplay(_INTL("{1} was freed from {2}!",i.pbThis,movename))
- else
- if isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:BIND)
- pbCommonAnimation("Bind",i,nil)
- elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:CLAMP)
- pbCommonAnimation("Clamp",i,nil)
- elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:FIRESPIN)
- pbCommonAnimation("FireSpin",i,nil)
- elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:MAGMASTORM)
- pbCommonAnimation("MagmaStorm",i,nil)
- elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:SANDTOMB)
- pbCommonAnimation("SandTomb",i,nil)
- elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:WRAP)
- pbCommonAnimation("Wrap",i,nil)
- elsif isConst?(i.effects[PBEffects::MultiTurnAttack],PBMoves,:INFESTATION)
- pbCommonAnimation("Infestation",i,nil)
- else
- pbCommonAnimation("Wrap",i,nil)
- end
- if !i.hasWorkingAbility(:MAGICGUARD)
- PBDebug.log("[Lingering effect triggered] #{i.pbThis} took damage from trapping move #{movename}")
- @scene.pbDamageAnimation(i,0)
- amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/8).floor : (i.totalhp/16).floor
- if @battlers[i.effects[PBEffects::MultiTurnUser]].hasWorkingItem(:BINDINGBAND)
- amt=(USENEWBATTLEMECHANICS) ? (i.totalhp/6).floor : (i.totalhp/8).floor
- end
- i.pbReduceHP(amt)
- pbDisplay(_INTL("{1} is hurt by {2}!",i.pbThis,movename))
- end
- end
- end
- if i.fainted?
- return if !i.pbFaint
- end
- end
- # Taunt
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Taunt]>0
- i.effects[PBEffects::Taunt]-=1
- if i.effects[PBEffects::Taunt]==0
- pbDisplay(_INTL("{1}'s taunt wore off!",i.pbThis))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer taunted")
- end
- end
- end
- # Encore
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Encore]>0
- if i.moves[i.effects[PBEffects::EncoreIndex]].id!=i.effects[PBEffects::EncoreMove]
- i.effects[PBEffects::Encore]=0
- i.effects[PBEffects::EncoreIndex]=0
- i.effects[PBEffects::EncoreMove]=0
- PBDebug.log("[End of effect] #{i.pbThis} is no longer encored (encored move was lost)")
- else
- i.effects[PBEffects::Encore]-=1
- if i.effects[PBEffects::Encore]==0 || i.moves[i.effects[PBEffects::EncoreIndex]].pp==0
- i.effects[PBEffects::Encore]=0
- pbDisplay(_INTL("{1}'s encore ended!",i.pbThis))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer encored")
- end
- end
- end
- end
- # Disable/Cursed Body
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Disable]>0
- i.effects[PBEffects::Disable]-=1
- if i.effects[PBEffects::Disable]==0
- i.effects[PBEffects::DisableMove]=0
- pbDisplay(_INTL("{1} is no longer disabled!",i.pbThis))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer disabled")
- end
- end
- end
- # Magnet Rise
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::MagnetRise]>0
- i.effects[PBEffects::MagnetRise]-=1
- if i.effects[PBEffects::MagnetRise]==0
- pbDisplay(_INTL("{1} stopped levitating.",i.pbThis))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer levitating by Magnet Rise")
- end
- end
- end
- # Telekinesis
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Telekinesis]>0
- i.effects[PBEffects::Telekinesis]-=1
- if i.effects[PBEffects::Telekinesis]==0
- pbDisplay(_INTL("{1} stopped levitating.",i.pbThis))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer levitating by Telekinesis")
- end
- end
- end
- # Heal Block
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::HealBlock]>0
- i.effects[PBEffects::HealBlock]-=1
- if i.effects[PBEffects::HealBlock]==0
- pbDisplay(_INTL("{1}'s Heal Block wore off!",i.pbThis))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer Heal Blocked")
- end
- end
- end
- # Embargo
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Embargo]>0
- i.effects[PBEffects::Embargo]-=1
- if i.effects[PBEffects::Embargo]==0
- pbDisplay(_INTL("{1} can use items again!",i.pbThis(true)))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer affected by an embargo")
- end
- end
- end
- # Yawn
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Yawn]>0
- i.effects[PBEffects::Yawn]-=1
- if i.effects[PBEffects::Yawn]==0 && i.pbCanSleepYawn?
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Yawn")
- i.pbSleep
- i.pbBerryCureCheck
- end
- end
- end
- # Perish Song
- perishSongUsers=[]
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::PerishSong]>0
- i.effects[PBEffects::PerishSong]-=1
- pbDisplay(_INTL("{1}'s perish count fell to {2}!",i.pbThis,i.effects[PBEffects::PerishSong]))
- PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Perish Song count dropped to #{i.effects[PBEffects::PerishSong]}")
- if i.effects[PBEffects::PerishSong]==0
- perishSongUsers.push(i.effects[PBEffects::PerishSongUser])
- i.pbReduceHP(i.hp,true)
- end
- end
- if i.fainted?
- return if !i.pbFaint
- end
- end
- if perishSongUsers.length>0
- # If all remaining Pokemon fainted by a Perish Song triggered by a single side
- if (perishSongUsers.find_all{|item| pbIsOpposing?(item) }.length==perishSongUsers.length) ||
- (perishSongUsers.find_all{|item| !pbIsOpposing?(item) }.length==perishSongUsers.length)
- pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
- end
- end
- if @decision>0
- pbGainEXP
- return
- end
- # Reflect
- for i in 0...2
- if sides[i].effects[PBEffects::Reflect]>0
- sides[i].effects[PBEffects::Reflect]-=1
- if sides[i].effects[PBEffects::Reflect]==0
- pbDisplay(_INTL("Your team's Reflect faded!")) if i==0
- pbDisplay(_INTL("The opposing team's Reflect faded!")) if i==1
- PBDebug.log("[End of effect] Reflect ended on the player's side") if i==0
- PBDebug.log("[End of effect] Reflect ended on the opponent's side") if i==1
- end
- end
- end
- # Light Screen
- for i in 0...2
- if sides[i].effects[PBEffects::LightScreen]>0
- sides[i].effects[PBEffects::LightScreen]-=1
- if sides[i].effects[PBEffects::LightScreen]==0
- pbDisplay(_INTL("Your team's Light Screen faded!")) if i==0
- pbDisplay(_INTL("The opposing team's Light Screen faded!")) if i==1
- PBDebug.log("[End of effect] Light Screen ended on the player's side") if i==0
- PBDebug.log("[End of effect] Light Screen ended on the opponent's side") if i==1
- end
- end
- end
- # Safeguard
- for i in 0...2
- if sides[i].effects[PBEffects::Safeguard]>0
- sides[i].effects[PBEffects::Safeguard]-=1
- if sides[i].effects[PBEffects::Safeguard]==0
- pbDisplay(_INTL("Your team is no longer protected by Safeguard!")) if i==0
- pbDisplay(_INTL("The opposing team is no longer protected by Safeguard!")) if i==1
- PBDebug.log("[End of effect] Safeguard ended on the player's side") if i==0
- PBDebug.log("[End of effect] Safeguard ended on the opponent's side") if i==1
- end
- end
- end
- # Mist
- for i in 0...2
- if sides[i].effects[PBEffects::Mist]>0
- sides[i].effects[PBEffects::Mist]-=1
- if sides[i].effects[PBEffects::Mist]==0
- pbDisplay(_INTL("Your team's Mist faded!")) if i==0
- pbDisplay(_INTL("The opposing team's Mist faded!")) if i==1
- PBDebug.log("[End of effect] Mist ended on the player's side") if i==0
- PBDebug.log("[End of effect] Mist ended on the opponent's side") if i==1
- end
- end
- end
- # Tailwind
- for i in 0...2
- if sides[i].effects[PBEffects::Tailwind]>0
- sides[i].effects[PBEffects::Tailwind]-=1
- if sides[i].effects[PBEffects::Tailwind]==0
- pbDisplay(_INTL("Your team's Tailwind petered out!")) if i==0
- pbDisplay(_INTL("The opposing team's Tailwind petered out!")) if i==1
- PBDebug.log("[End of effect] Tailwind ended on the player's side") if i==0
- PBDebug.log("[End of effect] Tailwind ended on the opponent's side") if i==1
- end
- end
- end
- # Lucky Chant
- for i in 0...2
- if sides[i].effects[PBEffects::LuckyChant]>0
- sides[i].effects[PBEffects::LuckyChant]-=1
- if sides[i].effects[PBEffects::LuckyChant]==0
- pbDisplay(_INTL("Your team's Lucky Chant faded!")) if i==0
- pbDisplay(_INTL("The opposing team's Lucky Chant faded!")) if i==1
- PBDebug.log("[End of effect] Lucky Chant ended on the player's side") if i==0
- PBDebug.log("[End of effect] Lucky Chant ended on the opponent's side") if i==1
- end
- end
- end
- # End of Pledge move combinations
- for i in 0...2
- if sides[i].effects[PBEffects::Swamp]>0
- sides[i].effects[PBEffects::Swamp]-=1
- if sides[i].effects[PBEffects::Swamp]==0
- pbDisplay(_INTL("The swamp around your team disappeared!")) if i==0
- pbDisplay(_INTL("The swamp around the opposing team disappeared!")) if i==1
- PBDebug.log("[End of effect] Grass Pledge's swamp ended on the player's side") if i==0
- PBDebug.log("[End of effect] Grass Pledge's swamp ended on the opponent's side") if i==1
- end
- end
- if sides[i].effects[PBEffects::SeaOfFire]>0
- sides[i].effects[PBEffects::SeaOfFire]-=1
- if sides[i].effects[PBEffects::SeaOfFire]==0
- pbDisplay(_INTL("The sea of fire around your team disappeared!")) if i==0
- pbDisplay(_INTL("The sea of fire around the opposing team disappeared!")) if i==1
- PBDebug.log("[End of effect] Fire Pledge's sea of fire ended on the player's side") if i==0
- PBDebug.log("[End of effect] Fire Pledge's sea of fire ended on the opponent's side") if i==1
- end
- end
- if sides[i].effects[PBEffects::Rainbow]>0
- sides[i].effects[PBEffects::Rainbow]-=1
- if sides[i].effects[PBEffects::Rainbow]==0
- pbDisplay(_INTL("The rainbow around your team disappeared!")) if i==0
- pbDisplay(_INTL("The rainbow around the opposing team disappeared!")) if i==1
- PBDebug.log("[End of effect] Water Pledge's rainbow ended on the player's side") if i==0
- PBDebug.log("[End of effect] Water Pledge's rainbow ended on the opponent's side") if i==1
- end
- end
- end
- # Gravity
- if @field.effects[PBEffects::Gravity]>0
- @field.effects[PBEffects::Gravity]-=1
- if @field.effects[PBEffects::Gravity]==0
- pbDisplay(_INTL("Gravity returned to normal."))
- PBDebug.log("[End of effect] Strong gravity ended")
- end
- end
- # Trick Room
- if @field.effects[PBEffects::TrickRoom]>0
- @field.effects[PBEffects::TrickRoom]-=1
- if @field.effects[PBEffects::TrickRoom]==0
- pbDisplay(_INTL("The twisted dimensions returned to normal."))
- PBDebug.log("[End of effect] Trick Room ended")
- end
- end
- # Wonder Room
- if @field.effects[PBEffects::WonderRoom]>0
- @field.effects[PBEffects::WonderRoom]-=1
- if @field.effects[PBEffects::WonderRoom]==0
- pbDisplay(_INTL("Wonder Room wore off, and the Defense and Sp. Def stats returned to normal!"))
- PBDebug.log("[End of effect] Wonder Room ended")
- end
- end
- # Magic Room
- if @field.effects[PBEffects::MagicRoom]>0
- @field.effects[PBEffects::MagicRoom]-=1
- if @field.effects[PBEffects::MagicRoom]==0
- pbDisplay(_INTL("The area returned to normal."))
- PBDebug.log("[End of effect] Magic Room ended")
- end
- end
- # Mud Sport
- if @field.effects[PBEffects::MudSportField]>0
- @field.effects[PBEffects::MudSportField]-=1
- if @field.effects[PBEffects::MudSportField]==0
- pbDisplay(_INTL("The effects of Mud Sport have faded."))
- PBDebug.log("[End of effect] Mud Sport ended")
- end
- end
- # Water Sport
- if @field.effects[PBEffects::WaterSportField]>0
- @field.effects[PBEffects::WaterSportField]-=1
- if @field.effects[PBEffects::WaterSportField]==0
- pbDisplay(_INTL("The effects of Water Sport have faded."))
- PBDebug.log("[End of effect] Water Sport ended")
- end
- end
- # Electric Terrain
- if @field.effects[PBEffects::ElectricTerrain]>0
- @field.effects[PBEffects::ElectricTerrain]-=1
- if @field.effects[PBEffects::ElectricTerrain]==0
- pbDisplay(_INTL("The electric current disappeared from the battlefield."))
- PBDebug.log("[End of effect] Electric Terrain ended")
- end
- end
- # Grassy Terrain (counting down)
- if @field.effects[PBEffects::GrassyTerrain]>0
- @field.effects[PBEffects::GrassyTerrain]-=1
- if @field.effects[PBEffects::GrassyTerrain]==0
- pbDisplay(_INTL("The grass disappeared from the battlefield."))
- PBDebug.log("[End of effect] Grassy Terrain ended")
- end
- end
- # Misty Terrain
- if @field.effects[PBEffects::MistyTerrain]>0
- @field.effects[PBEffects::MistyTerrain]-=1
- if @field.effects[PBEffects::MistyTerrain]==0
- pbDisplay(_INTL("The mist disappeared from the battlefield."))
- PBDebug.log("[End of effect] Misty Terrain ended")
- end
- end
- # Uproar
- for i in priority
- next if i.fainted?
- if i.effects[PBEffects::Uproar]>0
- for j in priority
- if !j.fainted? && j.status==PBStatuses::SLEEP && !j.hasWorkingAbility(:SOUNDPROOF)
- PBDebug.log("[Lingering effect triggered] Uproar woke up #{j.pbThis(true)}")
- j.pbCureStatus(false)
- pbDisplay(_INTL("{1} woke up in the uproar!",j.pbThis))
- end
- end
- i.effects[PBEffects::Uproar]-=1
- if i.effects[PBEffects::Uproar]==0
- pbDisplay(_INTL("{1} calmed down.",i.pbThis))
- PBDebug.log("[End of effect] #{i.pbThis} is no longer uproaring")
- else
- pbDisplay(_INTL("{1} is making an uproar!",i.pbThis))
- end
- end
- end
- for i in priority
- next if i.fainted?
- # Speed Boost
- # A Pokémon's turncount is 0 if it became active after the beginning of a round
- if i.turncount>0 && i.hasWorkingAbility(:SPEEDBOOST)
- if i.pbIncreaseStatWithCause(PBStats::SPEED,1,i,PBAbilities.getName(i.ability))
- PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
- end
- end
- # Bad Dreams
- if i.status==PBStatuses::SLEEP && !i.hasWorkingAbility(:MAGICGUARD)
- if i.pbOpposing1.hasWorkingAbility(:BADDREAMS) ||
- i.pbOpposing2.hasWorkingAbility(:BADDREAMS)
- PBDebug.log("[Ability triggered] #{i.pbThis}'s opponent's Bad Dreams")
- hploss=i.pbReduceHP((i.totalhp/8).floor,true)
- pbDisplay(_INTL("{1} is having a bad dream!",i.pbThis)) if hploss>0
- end
- end
- if i.fainted?
- return if !i.pbFaint
- next
- end
- # Pickup
- if i.hasWorkingAbility(:PICKUP) && i.item<=0
- item=0; index=-1; use=0
- for j in 0...4
- next if j==i.index
- if @battlers[j].effects[PBEffects::PickupUse]>use
- item=@battlers[j].effects[PBEffects::PickupItem]
- index=j
- use=@battlers[j].effects[PBEffects::PickupUse]
- end
- end
- if item>0
- i.item=item
- @battlers[index].effects[PBEffects::PickupItem]=0
- @battlers[index].effects[PBEffects::PickupUse]=0
- @battlers[index].pokemon.itemRecycle=0 if @battlers[index].pokemon.itemRecycle==item
- if !@opponent && # In a wild battle
- i.pokemon.itemInitial==0 &&
- @battlers[index].pokemon.itemInitial==item
- i.pokemon.itemInitial=item
- @battlers[index].pokemon.itemInitial=0
- end
- pbDisplay(_INTL("{1} found one {2}!",i.pbThis,PBItems.getName(item)))
- i.pbBerryCureCheck(true)
- end
- end
- # Harvest
- if i.hasWorkingAbility(:HARVEST) && i.item<=0 && i.pokemon.itemRecycle>0
- if pbIsBerry?(i.pokemon.itemRecycle) &&
- (pbWeather==PBWeather::SUNNYDAY ||
- pbWeather==PBWeather::HARSHSUN || pbRandom(10)<5)
- i.item=i.pokemon.itemRecycle
- i.pokemon.itemRecycle=0
- i.pokemon.itemInitial=i.item if i.pokemon.itemInitial==0
- pbDisplay(_INTL("{1} harvested one {2}!",i.pbThis,PBItems.getName(i.item)))
- i.pbBerryCureCheck(true)
- end
- end
- # Moody
- if i.hasWorkingAbility(:MOODY)
- randomup=[]; randomdown=[]
- for j in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,PBStats::SPATK,
- PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
- randomup.push(j) if i.pbCanIncreaseStatStage?(j,i)
- randomdown.push(j) if i.pbCanReduceStatStage?(j,i)
- end
- if randomup.length>0
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Moody (raise stat)")
- r=pbRandom(randomup.length)
- i.pbIncreaseStatWithCause(randomup[r],2,i,PBAbilities.getName(i.ability))
- for j in 0...randomdown.length
- if randomdown[j]==randomup[r]
- randomdown[j]=nil; randomdown.compact!
- break
- end
- end
- end
- if randomdown.length>0
- PBDebug.log("[Ability triggered] #{i.pbThis}'s Moody (lower stat)")
- r=pbRandom(randomdown.length)
- i.pbReduceStatWithCause(randomdown[r],1,i,PBAbilities.getName(i.ability))
- end
- end
- end
- for i in priority
- next if i.fainted?
- # Toxic Orb
- if i.hasWorkingItem(:TOXICORB) && i.status==0 && i.pbCanPoison?(nil,false)
- PBDebug.log("[Item triggered] #{i.pbThis}'s Toxic Orb")
- i.pbPoison(nil,_INTL("{1} was badly poisoned by its {2}!",i.pbThis,
- PBItems.getName(i.item)),true)
- end
- # Flame Orb
- if i.hasWorkingItem(:FLAMEORB) && i.status==0 && i.pbCanBurn?(nil,false)
- PBDebug.log("[Item triggered] #{i.pbThis}'s Flame Orb")
- i.pbBurn(nil,_INTL("{1} was burned by its {2}!",i.pbThis,PBItems.getName(i.item)))
- end
- # Sticky Barb
- if i.hasWorkingItem(:STICKYBARB) && !i.hasWorkingAbility(:MAGICGUARD)
- PBDebug.log("[Item triggered] #{i.pbThis}'s Sticky Barb")
- @scene.pbDamageAnimation(i,0)
- i.pbReduceHP((i.totalhp/8).floor)
- pbDisplay(_INTL("{1} is hurt by its {2}!",i.pbThis,PBItems.getName(i.item)))
- end
- if i.fainted?
- return if !i.pbFaint
- end
- end
- # Slow Start's end message
- if i.hasWorkingAbility(:SLOWSTART) && i.turncount==6
- pbDisplay(_INTL("{1} finally got its act together!",i.pbThis))
- end
- # Form checks
- for i in 0...4
- next if @battlers[i].fainted?
- @battlers[i].pbCheckForm
- end
- pbGainEXP
- pbSwitch
- return if @decision>0
- for i in priority
- next if i.fainted?
- i.pbAbilitiesOnSwitchIn(false)
- end
- # Healing Wish/Lunar Dance - should go here
- # Spikes/Toxic Spikes/Stealth Rock - should go here (in order of their 1st use)
- for i in 0...4
- if @battlers[i].turncount>0 && @battlers[i].hasWorkingAbility(:TRUANT)
- @battlers[i].effects[PBEffects::Truant]=!@battlers[i].effects[PBEffects::Truant]
- end
- if @battlers[i].effects[PBEffects::LockOn]>0 # Also Mind Reader
- @battlers[i].effects[PBEffects::LockOn]-=1
- @battlers[i].effects[PBEffects::LockOnPos]=-1 if @battlers[i].effects[PBEffects::LockOn]==0
- end
- @battlers[i].effects[PBEffects::Flinch]=false
- @battlers[i].effects[PBEffects::FollowMe]=0
- @battlers[i].effects[PBEffects::HelpingHand]=false
- @battlers[i].effects[PBEffects::MagicCoat]=false
- @battlers[i].effects[PBEffects::Snatch]=false
- @battlers[i].effects[PBEffects::Charge]-=1 if @battlers[i].effects[PBEffects::Charge]>0
- @battlers[i].lastHPLost=0
- @battlers[i].tookDamage=false
- @battlers[i].lastAttacker.clear
- @battlers[i].effects[PBEffects::Counter]=-1
- @battlers[i].effects[PBEffects::CounterTarget]=-1
- @battlers[i].effects[PBEffects::MirrorCoat]=-1
- @battlers[i].effects[PBEffects::MirrorCoatTarget]=-1
- end
- for i in 0...2
- if !@sides[i].effects[PBEffects::EchoedVoiceUsed]
- @sides[i].effects[PBEffects::EchoedVoiceCounter]=0
- end
- @sides[i].effects[PBEffects::EchoedVoiceUsed]=false
- @sides[i].effects[PBEffects::MatBlock]= false
- @sides[i].effects[PBEffects::QuickGuard]=false
- @sides[i].effects[PBEffects::WideGuard]=false
- @sides[i].effects[PBEffects::CraftyShield]=false
- @sides[i].effects[PBEffects::Round]=0
- end
- @field.effects[PBEffects::FusionBolt]=false
- @field.effects[PBEffects::FusionFlare]=false
- @field.effects[PBEffects::IonDeluge]=false
- @field.effects[PBEffects::FairyLock]-=1 if @field.effects[PBEffects::FairyLock]>0
- # invalidate stored priority
- @usepriority=false
- end
- ################################################################################
- # End of battle.
- ################################################################################
- def pbEndOfBattle(canlose=false)
- case @decision
- ##### WIN #####
- when 1
- PBDebug.log("")
- PBDebug.log("***Player won***")
- if @opponent
- @scene.pbTrainerBattleSuccess
- if @opponent.is_a?(Array)
- pbDisplayPaused(_INTL("{1} defeated {2} and {3}!",self.pbPlayer.name,@opponent[0].fullname,@opponent[1].fullname))
- else
- pbDisplayPaused(_INTL("{1} defeated\r\n{2}!",self.pbPlayer.name,@opponent.fullname))
- end
- @scene.pbShowOpponent(0)
- pbDisplayPaused(@endspeech.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
- if @opponent.is_a?(Array)
- @scene.pbHideOpponent
- @scene.pbShowOpponent(1)
- pbDisplayPaused(@endspeech2.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
- end
- # Calculate money gained for winning
- if @internalbattle
- tmoney=0
- if @opponent.is_a?(Array) # Double battles
- maxlevel1=0; maxlevel2=0; limit=pbSecondPartyBegin(1)
- for i in 0...limit
- if @party2[i]
- maxlevel1=@party2[i].level if maxlevel1<@party2[i].level
- end
- if @party2[i+limit]
- maxlevel2=@party2[i+limit].level if maxlevel1<@party2[i+limit].level
- end
- end
- tmoney+=maxlevel1*@opponent[0].moneyEarned
- tmoney+=maxlevel2*@opponent[1].moneyEarned
- else
- maxlevel=0
- for i in @party2
- next if !i
- maxlevel=i.level if maxlevel<i.level
- end
- tmoney+=maxlevel*@opponent.moneyEarned
- end
- # If Amulet Coin/Luck Incense's effect applies, double money earned
- tmoney*=2 if @amuletcoin
- # If Happy Hour's effect applies, double money earned
- tmoney*=2 if @doublemoney
- oldmoney=self.pbPlayer.money
- self.pbPlayer.money+=tmoney
- moneygained=self.pbPlayer.money-oldmoney
- if moneygained>0
- pbDisplayPaused(_INTL("{1} got ${2}\r\nfor winning!",self.pbPlayer.name,pbCommaNumber(tmoney)))
- end
- end
- end
- if @internalbattle && @extramoney>0
- @extramoney*=2 if @amuletcoin
- @extramoney*=2 if @doublemoney
- oldmoney=self.pbPlayer.money
- self.pbPlayer.money+=@extramoney
- moneygained=self.pbPlayer.money-oldmoney
- if moneygained>0
- pbDisplayPaused(_INTL("{1} picked up ${2}!",self.pbPlayer.name,pbCommaNumber(@extramoney)))
- end
- end
- for pkmn in @snaggedpokemon
- pbStorePokemon(pkmn)
- self.pbPlayer.shadowcaught=[] if !self.pbPlayer.shadowcaught
- self.pbPlayer.shadowcaught[pkmn.species]=true
- end
- @snaggedpokemon.clear
- ##### LOSE, DRAW #####
- when 2, 5
- PBDebug.log("")
- PBDebug.log("***Player lost***") if @decision==2
- PBDebug.log("***Player drew with opponent***") if @decision==5
- if @internalbattle
- moneylost=pbMaxLevelFromIndex(0) # Player's Pokémon only, not partner's
- multiplier=[8,16,24,36,48,64,80,100,120]
- moneylost*=multiplier[[multiplier.length-1,self.pbPlayer.numbadges].min]
- moneylost=self.pbPlayer.money if moneylost>self.pbPlayer.money
- moneylost=0 if $game_switches[NO_MONEY_LOSS]
- oldmoney=self.pbPlayer.money
- self.pbPlayer.money-=moneylost
- lostmoney=oldmoney-self.pbPlayer.money
- if @opponent
- if @opponent.is_a?(Array)
- pbDisplayPaused(_INTL("You lost against {1} and {2}!",@opponent[0].fullname,@opponent[1].fullname))
- else
- pbDisplayPaused(_INTL("You lost against\r\n{1}!",@opponent.fullname))
- end
- if moneylost>0
- pbDisplayPaused(_INTL("You gave ${1} to the winner...",pbCommaNumber(lostmoney)))
- end
- else
- pbDisplayPaused(_INTL("You have no more Pokémon that can fight!"))
- if moneylost>0
- pbDisplayPaused(_INTL("You panicked and dropped\r\n${1}...",pbCommaNumber(lostmoney)))
- end
- end
- pbDisplayPaused(_INTL("You blacked out!")) if !canlose
- elsif @decision==2
- @scene.pbShowOpponent(0)
- pbDisplayPaused(@endspeechwin.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
- if @opponent.is_a?(Array)
- @scene.pbHideOpponent
- @scene.pbShowOpponent(1)
- pbDisplayPaused(@endspeechwin2.gsub(/\\[Pp][Nn]/,self.pbPlayer.name))
- end
- end
- end
- # Pass on Pokérus within the party
- infected=[]
- for i in 0...$Trainer.party.length
- if $Trainer.party[i].pokerusStage==1
- infected.push(i)
- end
- end
- if infected.length>=1
- for i in infected
- strain=$Trainer.party[i].pokerusStrain
- if i>0 && $Trainer.party[i-1].pokerusStage==0
- $Trainer.party[i-1].givePokerus(strain) if rand(3)==0
- end
- if i<$Trainer.party.length-1 && $Trainer.party[i+1].pokerusStage==0
- $Trainer.party[i+1].givePokerus(strain) if rand(3)==0
- end
- end
- end
- @scene.pbEndBattle(@decision)
- for i in @battlers
- i.pbResetForm
- if i.hasWorkingAbility(:NATURALCURE)
- i.status=0
- end
- end
- for i in $Trainer.party
- i.setItem(i.itemInitial)
- i.itemInitial=i.itemRecycle=0
- i.belch=false
- end
- return @decision
- end
- end
- ################################################################################
- # Pokemon Storing PokeBattle_BattlePeer #
- ################################################################################
- class PokeBattle_NullBattlePeer
- def pbOnEnteringBattle(battle,pokemon)
- end
- def pbStorePokemon(player,pokemon)
- if $Trainer.partyplus>=1
- if player.party.length<$Trainer.partyplus
- player.party[player.party.length]=pokemon
- end
- else
- if player.party.length<6
- player.party[player.party.length]=pokemon
- end
- end
- return -1
- end
- def pbGetStorageCreator()
- return nil
- end
- def pbCurrentBox()
- return -1
- end
- def pbBoxName(box)
- return ""
- end
- end
- class PokeBattle_RealBattlePeer
- def pbStorePokemon(player,pokemon)
- if $Trainer.partyplus>=1
- if player.party.length<$Trainer.partyplus
- player.party[player.party.length]=pokemon
- return -1
- else
- pokemon.heal
- oldcurbox=$PokemonStorage.currentBox
- storedbox=$PokemonStorage.pbStoreCaught(pokemon)
- if storedbox<0
- pbDisplayPaused(_INTL("Can't catch any more..."))
- return oldcurbox
- else
- return storedbox
- end
- end
- else
- if player.party.length<6
- player.party[player.party.length]=pokemon
- return -1
- else
- pokemon.heal
- oldcurbox=$PokemonStorage.currentBox
- storedbox=$PokemonStorage.pbStoreCaught(pokemon)
- if storedbox<0
- pbDisplayPaused(_INTL("Can't catch any more..."))
- return oldcurbox
- else
- return storedbox
- end
- end
- end
- end
- def pbGetStorageCreator()
- creator=nil
- if $PokemonGlobal && $PokemonGlobal.seenStorageCreator
- creator=Kernel.pbGetStorageCreator
- end
- return creator
- end
- def pbCurrentBox()
- return $PokemonStorage.currentBox
- end
- def pbBoxName(box)
- return box<0 ? "" : $PokemonStorage[box].name
- end
- end
- class PokeBattle_BattlePeer
- def self.create
- return PokeBattle_RealBattlePeer.new
- end
- end
- ################################################################################
- # Daycare Methods PField_DayCare #
- ################################################################################
- def pbDayCareWithdraw(index)
- if $Trainer.partyplus>=1
- if !$PokemonGlobal.daycare[index][0]
- raise _INTL("There's no Pokémon here...")
- elsif $Trainer.party.length>=$Trainer.partyplus
- raise _INTL("Can't store the Pokémon...")
- else
- $Trainer.party[$Trainer.party.length]=$PokemonGlobal.daycare[index][0]
- $PokemonGlobal.daycare[index][0]=nil
- $PokemonGlobal.daycare[index][1]=0
- $PokemonGlobal.daycareEgg=0
- end
- else
- if !$PokemonGlobal.daycare[index][0]
- raise _INTL("There's no Pokémon here...")
- elsif $Trainer.party.length>=6
- raise _INTL("Can't store the Pokémon...")
- else
- $Trainer.party[$Trainer.party.length]=$PokemonGlobal.daycare[index][0]
- $PokemonGlobal.daycare[index][0]=nil
- $PokemonGlobal.daycare[index][1]=0
- $PokemonGlobal.daycareEgg=0
- end
- end
- end
- def pbDayCareGenerateEgg
- return if pbDayCareDeposited!=2
- if $Trainer.partyplus>=1
- if $Trainer.party.length>=$Trainer.partyplus
- raise _INTL("Can't store the egg")
- end
- else
- if $Trainer.party.length>=6
- raise _INTL("Can't store the egg")
- end
- end
- pokemon0=$PokemonGlobal.daycare[0][0]
- pokemon1=$PokemonGlobal.daycare[1][0]
- mother=nil
- father=nil
- babyspecies=0
- ditto0=pbIsDitto?(pokemon0)
- ditto1=pbIsDitto?(pokemon1)
- if pokemon0.isFemale? || ditto0
- babyspecies=(ditto0) ? pokemon1.species : pokemon0.species
- mother=pokemon0
- father=pokemon1
- else
- babyspecies=(ditto1) ? pokemon0.species : pokemon1.species
- mother=pokemon1
- father=pokemon0
- end
- babyspecies=pbGetBabySpecies(babyspecies,mother.item,father.item)
- if isConst?(babyspecies,PBSpecies,:MANAPHY) && hasConst?(PBSpecies,:PHIONE)
- babyspecies=getConst(PBSpecies,:PHIONE)
- elsif (isConst?(babyspecies,PBSpecies,:NIDORANfE) && hasConst?(PBSpecies,:NIDORANmA)) ||
- (isConst?(babyspecies,PBSpecies,:NIDORANmA) && hasConst?(PBSpecies,:NIDORANfE))
- babyspecies=[getConst(PBSpecies,:NIDORANmA),
- getConst(PBSpecies,:NIDORANfE)][rand(2)]
- elsif (isConst?(babyspecies,PBSpecies,:VOLBEAT) && hasConst?(PBSpecies,:ILLUMISE)) ||
- (isConst?(babyspecies,PBSpecies,:ILLUMISE) && hasConst?(PBSpecies,:VOLBEAT))
- babyspecies=[getConst(PBSpecies,:VOLBEAT),
- getConst(PBSpecies,:ILLUMISE)][rand(2)]
- end
- # Generate egg
- egg=PokeBattle_Pokemon.new(babyspecies,EGGINITIALLEVEL,$Trainer)
- # Randomise personal ID
- pid=rand(65536)
- pid|=(rand(65536)<<16)
- egg.personalID=pid
- # Inheriting form
- if isConst?(babyspecies,PBSpecies,:BURMY) ||
- isConst?(babyspecies,PBSpecies,:SHELLOS) ||
- isConst?(babyspecies,PBSpecies,:BASCULIN) ||
- isConst?(babyspecies,PBSpecies,:FLABEBE) ||
- isConst?(babyspecies,PBSpecies,:PUMPKABOO) ||
- isConst?(babyspecies,PBSpecies,:ORICORIO) ||
- isConst?(babyspecies,PBSpecies,:MINIOR)
- egg.form=mother.form
- end
- # Inheriting Moves
- moves=[]
- othermoves=[]
- movefather=father; movemother=mother
- if pbIsDitto?(movefather) && !mother.isFemale?
- movefather=mother; movemother=father
- end
- # Initial Moves
- initialmoves=egg.getMoveList
- for k in initialmoves
- if k[0]<=EGGINITIALLEVEL
- moves.push(k[1])
- else
- othermoves.push(k[1]) if mother.hasMove?(k[1]) && father.hasMove?(k[1])
- end
- end
- # Inheriting Natural Moves
- for move in othermoves
- moves.push(move)
- end
- # Inheriting Machine Moves
- if !USENEWBATTLEMECHANICS
- for i in 0...$ItemData.length
- next if !$ItemData[i]
- atk=$ItemData[i][ITEMMACHINE]
- next if !atk || atk==0
- if egg.isCompatibleWithMove?(atk)
- moves.push(atk) if movefather.hasMove?(atk)
- end
- end
- end
- # Inheriting Egg Moves
- if movefather.isMale?
- pbRgssOpen("Data/eggEmerald.dat","rb"){|f|
- f.pos=(egg.fSpecies-1)*8
- offset=f.fgetdw
- length=f.fgetdw
- if length>0
- f.pos=offset
- i=0; loop do break unless i<length
- atk=f.fgetw
- moves.push(atk) if movefather.hasMove?(atk)
- i+=1
- end
- end
- }
- end
- if USENEWBATTLEMECHANICS
- pbRgssOpen("Data/eggEmerald.dat","rb"){|f|
- f.pos=(egg.fSpecies-1)*8
- offset=f.fgetdw
- length=f.fgetdw
- if length>0
- f.pos=offset
- i=0; loop do break unless i<length
- atk=f.fgetw
- moves.push(atk) if movemother.hasMove?(atk)
- i+=1
- end
- end
- }
- end
- # Volt Tackle
- lightball=false
- if (isConst?(father.species,PBSpecies,:PIKACHU) ||
- isConst?(father.species,PBSpecies,:RAICHU)) &&
- isConst?(father.item,PBItems,:LIGHTBALL)
- lightball=true
- end
- if (isConst?(mother.species,PBSpecies,:PIKACHU) ||
- isConst?(mother.species,PBSpecies,:RAICHU)) &&
- isConst?(mother.item,PBItems,:LIGHTBALL)
- lightball=true
- end
- if lightball && isConst?(babyspecies,PBSpecies,:PICHU) &&
- hasConst?(PBMoves,:VOLTTACKLE)
- moves.push(getConst(PBMoves,:VOLTTACKLE))
- end
- moves|=[] # remove duplicates
- # Assembling move list
- finalmoves=[]
- listend=moves.length-4
- listend=0 if listend<0
- j=0
- for i in listend..listend+3
- moveid=(i>=moves.length) ? 0 : moves[i]
- finalmoves[j]=PBMove.new(moveid)
- j+=1
- end
- # Inheriting Individual Values
- ivs=[]
- for i in 0...6
- ivs[i]=rand(32)
- end
- ivinherit=[]
- for i in 0...2
- parent=[mother,father][i]
- ivinherit[i]=PBStats::HP if isConst?(parent.item,PBItems,:POWERWEIGHT)
- ivinherit[i]=PBStats::ATTACK if isConst?(parent.item,PBItems,:POWERBRACER)
- ivinherit[i]=PBStats::DEFENSE if isConst?(parent.item,PBItems,:POWERBELT)
- ivinherit[i]=PBStats::SPEED if isConst?(parent.item,PBItems,:POWERANKLET)
- ivinherit[i]=PBStats::SPATK if isConst?(parent.item,PBItems,:POWERLENS)
- ivinherit[i]=PBStats::SPDEF if isConst?(parent.item,PBItems,:POWERBAND)
- end
- num=0; r=rand(2)
- for i in 0...2
- if ivinherit[r]!=nil
- parent=[mother,father][r]
- ivs[ivinherit[r]]=parent.iv[ivinherit[r]]
- num+=1
- break
- end
- r=(r+1)%2
- end
- stats=[PBStats::HP,PBStats::ATTACK,PBStats::DEFENSE,
- PBStats::SPEED,PBStats::SPATK,PBStats::SPDEF]
- limit=(USENEWBATTLEMECHANICS && (isConst?(mother.item,PBItems,:DESTINYKNOT) ||
- isConst?(father.item,PBItems,:DESTINYKNOT))) ? 5 : 3
- loop do
- freestats=[]
- for i in stats
- freestats.push(i) if !ivinherit.include?(i)
- end
- break if freestats.length==0
- r=freestats[rand(freestats.length)]
- parent=[mother,father][rand(2)]
- ivs[r]=parent.iv[r]
- ivinherit.push(r)
- num+=1
- break if num>=limit
- end
- # Inheriting nature
- newnatures=[]
- newnatures.push(mother.nature) if isConst?(mother.item,PBItems,:EVERSTONE)
- newnatures.push(father.nature) if isConst?(father.item,PBItems,:EVERSTONE)
- if newnatures.length>0
- egg.setNature(newnatures[rand(newnatures.length)])
- end
- # Masuda method and Shiny Charm
- shinyretries=0
- shinyretries+=5 if father.language!=mother.language
- shinyretries+=2 if hasConst?(PBItems,:SHINYCHARM) &&
- $PokemonBag.pbHasItem?(:SHINYCHARM)
- if shinyretries>0
- for i in 0...shinyretries
- break if egg.isShiny?
- egg.personalID=rand(65536)|(rand(65536)<<16)
- end
- end
- # Inheriting ability from the mother
- if (!ditto0 && !ditto1)
- if mother.hasHiddenAbility?
- egg.setAbility(mother.abilityIndex) if rand(10)<6
- else
- if rand(10)<8
- egg.setAbility(mother.abilityIndex)
- else
- egg.setAbility((mother.abilityIndex+1)%2)
- end
- end
- elsif ((!ditto0 && ditto1) || (!ditto1 && ditto0)) && USENEWBATTLEMECHANICS
- parent=(!ditto0) ? mother : father
- if parent.hasHiddenAbility?
- egg.setAbility(parent.abilityIndex) if rand(10)<6
- end
- end
- # Inheriting Poké Ball from the mother
- if mother.isFemale? &&
- !isConst?(pbBallTypeToBall(mother.ballused),PBItems,:MASTERBALL) &&
- !isConst?(pbBallTypeToBall(mother.ballused),PBItems,:CHERISHBALL)
- egg.ballused=mother.ballused
- end
- egg.iv[0]=ivs[0]
- egg.iv[1]=ivs[1]
- egg.iv[2]=ivs[2]
- egg.iv[3]=ivs[3]
- egg.iv[4]=ivs[4]
- egg.iv[5]=ivs[5]
- egg.moves[0]=finalmoves[0]
- egg.moves[1]=finalmoves[1]
- egg.moves[2]=finalmoves[2]
- egg.moves[3]=finalmoves[3]
- egg.calcStats
- egg.obtainText=_INTL("Day-Care Couple")
- egg.name=_INTL("Egg")
- dexdata=pbOpenDexData
- pbDexDataOffset(dexdata,babyspecies,21)
- eggsteps=dexdata.fgetw
- dexdata.close
- egg.eggsteps=eggsteps
- if rand(65536)<POKERUSCHANCE
- egg.givePokerus
- end
- $Trainer.party[$Trainer.party.length]=egg
- end
- ################################################################################
- # Evolution #
- ################################################################################
- def pbEvolutionSuccess
- # Play cry of evolved species
- frames = pbCryFrameLength(@newspecies,@pokemon.form)
- pbBGMStop
- pbPlayCrySpecies(@newspecies,@pokemon.form)
- frames.times do
- Graphics.update
- pbUpdate
- end
- # Success jingle/message
- pbMEPlay("Evolution success")
- newspeciesname = PBSpecies.getName(@newspecies)
- oldspeciesname = PBSpecies.getName(@pokemon.species)
- Kernel.pbMessageDisplay(@sprites["msgwindow"],
- _INTL("\\se[]Congratulations! Your {1} evolved into {2}!\\wt[80]",
- @pokemon.name,newspeciesname)) { pbUpdate }
- @sprites["msgwindow"].text = ""
- # Check for consumed item and Pokémon duplication (i.e. Shedinja)
- removeItem = false
- createSpecies = pbCheckEvolutionEx(@pokemon){|pokemon,evonib,level,poke|
- case evonib
- when PBEvolution::Shedinja
- next poke if $PokemonBag.pbHasItem?(getConst(PBItems,:POKEBALL))
- when PBEvolution::TradeItem,PBEvolution::DayHoldItem,PBEvolution::NightHoldItem
- removeItem = true if poke==@newspecies # Item is now consumed
- end
- next -1
- }
- @pokemon.setItem(0) if removeItem
- # Modify Pokémon to make it evolved
- @pokemon.species = @newspecies
- @pokemon.name = newspeciesname if @pokemon.name==oldspeciesname
- @pokemon.form = 0 if isConst?(@pokemon.species,PBSpecies,:MOTHIM)
- @pokemon.calcStats
- # See and own evolved species
- $Trainer.seen[@newspecies] = true
- $Trainer.owned[@newspecies] = true
- pbSeenForm(@pokemon)
- # Learn moves upon evolution for evolved species
- movelist = @pokemon.getMoveList
- for i in movelist
- if i[0]==0 || i[0]==@pokemon.level # Learned a new move
- pbLearnMove(@pokemon,i[1],true) { pbUpdate }
- end
- end
- # Duplicate Pokémon (i.e. Shedinja)
- if $Trainer.partyplus>=1
- if createSpecies>0 && $Trainer.party.length<$Trainer.partyplus
- newpokemon = @pokemon.clone
- newpokemon.species = createSpecies
- newpokemon.name = PBSpecies.getName(createSpecies)
- newpokemon.iv = @pokemon.iv.clone
- newpokemon.ev = @pokemon.ev.clone
- newpokemon.markings = 0
- newpokemon.ballused = 0
- newpokemon.setItem(0)
- newpokemon.clearAllRibbons
- newpokemon.calcStats
- newpokemon.heal
- # Add duplicate Pokémon to party
- $Trainer.party.push(newpokemon)
- # See and own duplicate Pokémon
- $Trainer.seen[createSpecies] = true
- $Trainer.owned[createSpecies] = true
- pbSeenForm(newpokemon)
- # Consume Poké Ball
- $PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
- end
- else
- if createSpecies>0 && $Trainer.party.length<6
- newpokemon = @pokemon.clone
- newpokemon.species = createSpecies
- newpokemon.name = PBSpecies.getName(createSpecies)
- newpokemon.iv = @pokemon.iv.clone
- newpokemon.ev = @pokemon.ev.clone
- newpokemon.markings = 0
- newpokemon.ballused = 0
- newpokemon.setItem(0)
- newpokemon.clearAllRibbons
- newpokemon.calcStats
- newpokemon.heal
- # Add duplicate Pokémon to party
- $Trainer.party.push(newpokemon)
- # See and own duplicate Pokémon
- $Trainer.seen[createSpecies] = true
- $Trainer.owned[createSpecies] = true
- pbSeenForm(newpokemon)
- # Consume Poké Ball
- $PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
- end
- end
- end
- ################################################################################
- # Party #
- ################################################################################
- #===============================================================================
- # Pokémon party panels
- #===============================================================================
- class PokemonPartyBlankPanel < SpriteWrapper
- attr_accessor :text
- def initialize(pokemon,index,viewport=nil)
- super(viewport)
- if $Trainer.partyplus==40
- self.x = [0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448][index]
- self.y = [0,0,0,0,0,0,0,0,64,64,64,64,64,64,64,64,128,128,128,128,128,128,128,128,192,192,192,192,192,192,192,192,256,256,256,256,256,256,256,256][index]
- elsif $Trainer.partyplus==35
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [0,0,0,0,0,0,0,64,64,64,64,64,64,64,128,128,128,128,128,128,128,192,192,192,192,192,192,192,256,256,256,256,256,256,256][index]
- elsif $Trainer.partyplus==32
- self.x = [0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448][index]
- self.y = [2,2,2,2,2,2,2,2,82,82,82,82,82,82,82,82,162,162,162,162,162,162,162,162,242,242,242,242,242,242,242,242][index]
- elsif $Trainer.partyplus==30
- self.x = [2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427][index]
- self.y = [2,2,2,2,2,2,66,66,66,66,66,66,130,130,130,130,130,130,194,194,194,194,194,194,258,258,258,258,258,258][index]
- elsif $Trainer.partyplus==28
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [2,2,2,2,2,2,2,82,82,82,82,82,82,82,162,162,162,162,162,162,162,242,242,242,242,242,242,242][index]
- elsif $Trainer.partyplus==25
- self.x = [2,104,206,308,410,2,104,206,308,410,2,104,206,308,410,2,104,206,308,410,2,104,206,308,410][index]
- self.y = [2,2,2,2,2,66,66,66,66,66,130,130,130,130,130,194,194,194,194,194,258,258,258,258,258][index]
- elsif $Trainer.partyplus==24
- self.x = [2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427][index]
- self.y = [2,2,2,2,2,2,82,82,82,82,82,82,162,162,162,162,162,162,242,242,242,242,242,242][index]
- elsif $Trainer.partyplus==21
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [2,2,2,2,2,2,2,108,108,108,108,108,108,108,214,214,214,214,214,214,214][index]
- elsif $Trainer.partyplus==20
- self.x = [2,104,206,308,410,2,104,206,308,410,2,104,206,308,410,2,104,206,308,410][index]
- self.y = [2,2,2,2,2,82,82,82,82,82,162,162,162,162,162,242,242,242,242,242][index]
- elsif $Trainer.partyplus==18
- self.x = [2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427][index]
- self.y = [2,2,2,2,2,2,108,108,108,108,108,108,214,214,214,214,214,214][index]
- elsif $Trainer.partyplus==16
- self.x = [2,129,257,384,2,129,257,384,2,129,257,384,2,129,257,384][index]
- self.y = [2,2,2,2,82,82,82,82,162,162,162,162,242,242,242,242][index]
- elsif $Trainer.partyplus==15
- self.x = [2,104,206,308,410,2,104,206,308,410,2,104,206,308,410][index]
- self.y = [2,2,2,2,2,108,108,108,108,108,214,214,214,214,214][index]
- elsif $Trainer.partyplus==14
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [2,2,2,2,2,2,2,161,161,161,161,161,161,161][index]
- elsif $Trainer.partyplus==12
- self.x = [2,172,342,2,172,342,2,172,342,2,172,342][index]
- self.y = [2,2,2,82,82,82,162,162,162,242,242,242][index]
- elsif $Trainer.partyplus==10
- self.x = [2,257,2,257,2,257,2,257,2,257][index]
- self.y = [2,2,66,66,130,130,194,194,258,258][index]
- elsif $Trainer.partyplus==9
- self.x = [2,172,342,2,172,342,2,172,342][index]
- self.y = [2,2,2,108,108,108,214,214,214][index]
- elsif $Trainer.partyplus==8
- self.x = [2,257,2,257,2,257,2,257][index]
- self.y = [2,2,82,82,162,162,242,242][index]
- elsif $Trainer.partyplus==5
- self.x = [2,2,2,2,2,][index]
- self.y = [2,66,130,194,258][index]
- elsif $Trainer.partyplus==4
- self.x = [2,258,2,258][index]
- self.y = [2,2,162,162][index]
- elsif $Trainer.partyplus==3
- self.x = [2,2,2][index]
- self.y = [2,108,214][index]
- elsif $Trainer.partyplus==2
- self.x = [2,257][index]
- self.y = [2,2][index]
- elsif $Trainer.partyplus==1
- self.x = [2][index]
- self.y = [2][index]
- else
- self.x = [2,257,2,257,2,257][index]
- self.y = [2,2,108,108,214,214][index]
- end
- if $Trainer.partyplus==40
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/40 - Party/panel_blank")
- elsif $Trainer.partyplus==35
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/35 - Party/panel_blank")
- elsif $Trainer.partyplus==32
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/32 - Party/panel_blank")
- elsif $Trainer.partyplus==30
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/30 - Party/panel_blank")
- elsif $Trainer.partyplus==28
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/28 - Party/panel_blank")
- elsif $Trainer.partyplus==25
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/25 - Party/panel_blank")
- elsif $Trainer.partyplus==24
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/24 - Party/panel_blank")
- elsif $Trainer.partyplus==21
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/21 - Party/panel_blank")
- elsif $Trainer.partyplus==20
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/20 - Party/panel_blank")
- elsif $Trainer.partyplus==18
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/18 - Party/panel_blank")
- elsif $Trainer.partyplus==16
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/16 - Party/panel_blank")
- elsif $Trainer.partyplus==15
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/15 - Party/panel_blank")
- elsif $Trainer.partyplus==14
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/14 - Party/panel_blank")
- elsif $Trainer.partyplus==12
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/12 - Party/panel_blank")
- elsif $Trainer.partyplus==10
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/10 - Party/panel_blank")
- elsif $Trainer.partyplus==9
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/19 - Party/panel_blank")
- elsif $Trainer.partyplus==8
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/8 - Party/panel_blank")
- elsif $Trainer.partyplus==5
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/5 - Party/panel_blank")
- elsif $Trainer.partyplus==4
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/4 - Party/panel_blank")
- elsif $Trainer.partyplus==3
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/3 - Party/panel_blank")
- elsif $Trainer.partyplus==2
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/2 - Party/panel_blank")
- elsif $Trainer.partyplus==1
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/PartyPlus/1 - Party/panel_blank")
- else
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/panel_blank")
- end
- self.bitmap = @panelbgsprite.bitmap
- @text = nil
- end
- def dispose
- @panelbgsprite.dispose
- super
- end
- def selected; return false; end
- def selected=(value); end
- def preselected; return false; end
- def preselected=(value); end
- def switching; return false; end
- def switching=(value); end
- def refresh; end
- end
- class PokemonPartyPanel < SpriteWrapper
- attr_reader :pokemon
- attr_reader :active
- attr_reader :selected
- attr_reader :preselected
- attr_reader :switching
- attr_accessor :text
- def initialize(pokemon,index,viewport=nil)
- super(viewport)
- @pokemon = pokemon
- @active = (index==0) # true = rounded panel, false = rectangular panel
- @refreshing = true
- if $Trainer.partyplus==40
- self.x = [0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448][index]
- self.y = [0,0,0,0,0,0,0,0,64,64,64,64,64,64,64,64,128,128,128,128,128,128,128,128,192,192,192,192,192,192,192,192,256,256,256,256,256,256,256,256][index]
- elsif $Trainer.partyplus==35
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [0,0,0,0,0,0,0,64,64,64,64,64,64,64,128,128,128,128,128,128,128,192,192,192,192,192,192,192,256,256,256,256,256,256,256][index]
- elsif $Trainer.partyplus==32
- self.x = [0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448,0,64,128,192,256,320,384,448][index]
- self.y = [2,2,2,2,2,2,2,2,82,82,82,82,82,82,82,82,162,162,162,162,162,162,162,162,242,242,242,242,242,242,242,242][index]
- elsif $Trainer.partyplus==30
- self.x = [2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427][index]
- self.y = [2,2,2,2,2,2,66,66,66,66,66,66,130,130,130,130,130,130,194,194,194,194,194,194,258,258,258,258,258,258][index]
- elsif $Trainer.partyplus==28
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [2,2,2,2,2,2,2,82,82,82,82,82,82,82,162,162,162,162,162,162,162,242,242,242,242,242,242,242][index]
- elsif $Trainer.partyplus==25
- self.x = [2,104,206,308,410,2,104,206,308,410,2,104,206,308,410,2,104,206,308,410,2,104,206,308,410][index]
- self.y = [2,2,2,2,2,66,66,66,66,66,130,130,130,130,130,194,194,194,194,194,258,258,258,258,258][index]
- elsif $Trainer.partyplus==24
- self.x = [2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427][index]
- self.y = [2,2,2,2,2,2,82,82,82,82,82,82,162,162,162,162,162,162,242,242,242,242,242,242][index]
- elsif $Trainer.partyplus==21
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [2,2,2,2,2,2,2,108,108,108,108,108,108,108,214,214,214,214,214,214,214][index]
- elsif $Trainer.partyplus==20
- self.x = [2,104,206,308,410,2,104,206,308,410,2,104,206,308,410,2,104,206,308,410][index]
- self.y = [2,2,2,2,2,82,82,82,82,82,162,162,162,162,162,242,242,242,242,242][index]
- elsif $Trainer.partyplus==18
- self.x = [2,87,172,257,342,427,2,87,172,257,342,427,2,87,172,257,342,427][index]
- self.y = [2,2,2,2,2,2,108,108,108,108,108,108,214,214,214,214,214,214][index]
- elsif $Trainer.partyplus==16
- self.x = [2,129,257,384,2,129,257,384,2,129,257,384,2,129,257,384][index]
- self.y = [2,2,2,2,82,82,82,82,162,162,162,162,242,242,242,242][index]
- elsif $Trainer.partyplus==15
- self.x = [2,104,206,308,410,2,104,206,308,410,2,104,206,308,410][index]
- self.y = [2,2,2,2,2,108,108,108,108,108,214,214,214,214,214][index]
- elsif $Trainer.partyplus==14
- self.x = [2,75,148,221,294,367,440,2,75,148,221,294,367,440][index]
- self.y = [2,2,2,2,2,2,2,161,161,161,161,161,161,161][index]
- elsif $Trainer.partyplus==12
- self.x = [2,172,342,2,172,342,2,172,342,2,172,342][index]
- self.y = [2,2,2,82,82,82,162,162,162,242,242,242][index]
- elsif $Trainer.partyplus==10
- self.x = [2,257,2,257,2,257,2,257,2,257][index]
- self.y = [2,2,66,66,130,130,194,194,258,258][index]
- elsif $Trainer.partyplus==9
- self.x = [2,172,342,2,172,342,2,172,342][index]
- self.y = [2,2,2,108,108,108,214,214,214][index]
- elsif $Trainer.partyplus==8
- self.x = [2,257,2,257,2,257,2,257][index]
- self.y = [2,2,82,82,162,162,242,242][index]
- elsif $Trainer.partyplus==5
- self.x = [2,2,2,2,2,][index]
- self.y = [2,66,130,194,258][index]
- elsif $Trainer.partyplus==4
- self.x = [2,258,2,258][index]
- self.y = [2,2,162,162][index]
- elsif $Trainer.partyplus==3
- self.x = [2,2,2][index]
- self.y = [2,108,214][index]
- elsif $Trainer.partyplus==2
- self.x = [2,257][index]
- self.y = [2,2][index]
- elsif $Trainer.partyplus==1
- self.x = [2][index]
- self.y = [2][index]
- else
- self.x = [2,257,2,257,2,257][index]
- self.y = [2,2,108,108,214,214][index]
- end
- @panelbgsprite = ChangelingSprite.new(0,0,viewport)
- @panelbgsprite.z = self.z
- if $Trainer.partyplus==40
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/40 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/40 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/40 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/40 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/40 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/40 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/40 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==35
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/35 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/35 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/35 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/35 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/35 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/35 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/35 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==32
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/32 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/32 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/32 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/32 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/32 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/32 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/32 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==30
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/30 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/30 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/30 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/30 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/30 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/30 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/30 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==28
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/28 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/28 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/28 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/28 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/28 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/28 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/28 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==25
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/25 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/25 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/25 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/25 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/25 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/25 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/25 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==24
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/24 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/24 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/24 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/24 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/24 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/24 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/24 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==21
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/21 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/21 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/21 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/21 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/21 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/21 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/21 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==20
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/20 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/20 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/20 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/20 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/20 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/20 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/20 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==18
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/18 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/18 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/18 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/18 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/18 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/18 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/18 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==16
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/16 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/16 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/16 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/16 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/16 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/16 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/16 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==15
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/15 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/15 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/15 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/15 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/15 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/15 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/15 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==14
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/14 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/14 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/14 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/14 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/14 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/14 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/14 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==12
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/12 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/12 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/12 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/12 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/12 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/12 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/12 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==10
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/10 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/10 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/10 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/10 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/10 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/10 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/10 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==9
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/9 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/9 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/9 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/9 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/9 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/9 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/9 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==8
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/8 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/8 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/8 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/8 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/8 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/8 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/8 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==5
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/5 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/5 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/5 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/5 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/5 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/5 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/5 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==4
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/4 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/4 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/4 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/4 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/4 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/4 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/4 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==3
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/3 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/3 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/3 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/3 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/3 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/3 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/3 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==2
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/2 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/2 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/2 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/2 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/2 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/2 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/2 - Party/panel_rect_swap_sel2")
- elsif $Trainer.partyplus==1
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/PartyPlus/1 - Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/PartyPlus/1 - Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/PartyPlus/1 - Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/PartyPlus/1 - Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/PartyPlus/1 - Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/PartyPlus/1 - Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/PartyPlus/1 - Party/panel_rect_swap_sel2")
- else
- if @active # Rounded panel
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_round")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_round_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_round_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_round_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_round_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_round_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_round_swap_sel2")
- else # Rectangular panel
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_rect_swap_sel2")
- end
- end
- if $Trainer.partyplus>=1
- else
- @hpbgsprite = ChangelingSprite.new(0,0,viewport)
- @hpbgsprite.z = self.z+1
- @hpbgsprite.addBitmap("able","Graphics/Pictures/Party/overlay_hp_back")
- @hpbgsprite.addBitmap("fainted","Graphics/Pictures/Party/overlay_hp_back_faint")
- @hpbgsprite.addBitmap("swap","Graphics/Pictures/Party/overlay_hp_back_swap")
- @hpbar = AnimatedBitmap.new("Graphics/Pictures/Party/overlay_hp")
- end
- @ballsprite = ChangelingSprite.new(0,0,viewport)
- @ballsprite.z = self.z+1
- @ballsprite.addBitmap("desel","Graphics/Pictures/Party/icon_ball")
- @ballsprite.addBitmap("sel","Graphics/Pictures/Party/icon_ball_sel")
- @pkmnsprite = PokemonIconSprite.new(pokemon,viewport)
- @pkmnsprite.active = @active
- @pkmnsprite.z = self.z+2
- @helditemsprite = HeldItemIconSprite.new(0,0,@pokemon,viewport)
- @helditemsprite.z = self.z+3
- @overlaysprite = BitmapSprite.new(Graphics.width,Graphics.height,viewport)
- @overlaysprite.z = self.z+4
- @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses"))
- @selected = false
- @preselected = false
- @switching = false
- @text = nil
- @refreshBitmap = true
- @refreshing = false
- refresh
- end
- def dispose
- @panelbgsprite.dispose
- if $Trainer.partyplus>=1
- else
- @hpbgsprite.dispose
- @hpbar.dispose
- end
- @ballsprite.dispose
- @pkmnsprite.dispose
- @helditemsprite.dispose
- @overlaysprite.bitmap.dispose
- @overlaysprite.dispose
- @statuses.dispose
- super
- end
- def x=(value)
- super
- refresh
- end
- def y=(value)
- super
- refresh
- end
- def color=(value)
- super
- refresh
- end
- def text=(value)
- if @text!=value
- @text = value
- @refreshBitmap = true
- refresh
- end
- end
- def pokemon=(value)
- @pokemon = value
- @pkmnsprite.pokemon = value if @pkmnsprite && !@pkmnsprite.disposed?
- @helditemsprite.pokemon = value if @helditemsprite && !@helditemsprite.disposed?
- @refreshBitmap = true
- refresh
- end
- def selected=(value)
- if @selected!=value
- @selected = value
- refresh
- end
- end
- def preselected=(value)
- if @preselected!=value
- @preselected = value
- refresh
- end
- end
- def switching=(value)
- if @switching!=value
- @switching = value
- refresh
- end
- end
- def hp; return @pokemon.hp; end
- def refresh
- return if disposed?
- return if @refreshing
- @refreshing = true
- if @panelbgsprite && !@panelbgsprite.disposed?
- if self.selected
- if self.preselected; @panelbgsprite.changeBitmap("swapsel2")
- elsif @switching; @panelbgsprite.changeBitmap("swapsel")
- elsif @pokemon.fainted?; @panelbgsprite.changeBitmap("faintedsel")
- else; @panelbgsprite.changeBitmap("ablesel")
- end
- else
- if self.preselected; @panelbgsprite.changeBitmap("swap")
- elsif @pokemon.fainted?; @panelbgsprite.changeBitmap("fainted")
- else; @panelbgsprite.changeBitmap("able")
- end
- end
- @panelbgsprite.x = self.x
- @panelbgsprite.y = self.y
- @panelbgsprite.color = self.color
- end
- if $Trainer.partyplus>=1
- else
- if @hpbgsprite && !@hpbgsprite.disposed?
- @hpbgsprite.visible = (!@pokemon.egg? && !(@text && @text.length>0))
- if @hpbgsprite.visible
- if self.preselected || (self.selected && @switching); @hpbgsprite.changeBitmap("swap")
- elsif @pokemon.fainted?; @hpbgsprite.changeBitmap("fainted")
- else; @hpbgsprite.changeBitmap("able")
- end
- @hpbgsprite.x = self.x+96
- @hpbgsprite.y = self.y+50
- @hpbgsprite.color = self.color
- end
- end
- end
- if @ballsprite && !@ballsprite.disposed?
- @ballsprite.changeBitmap((self.selected) ? "sel" : "desel")
- @ballsprite.x = self.x+10
- @ballsprite.y = self.y+4
- @ballsprite.color = self.color
- end
- if @pkmnsprite && !@pkmnsprite.disposed?
- @pkmnsprite.x = self.x
- @pkmnsprite.y = self.y
- @pkmnsprite.color = self.color
- @pkmnsprite.selected = self.selected
- end
- if @helditemsprite && !@helditemsprite.disposed?
- if @helditemsprite.visible
- @helditemsprite.x = self.x+46
- @helditemsprite.y = self.y+46
- @helditemsprite.color = self.color
- end
- end
- if @overlaysprite && !@overlaysprite.disposed?
- @overlaysprite.x = self.x
- @overlaysprite.y = self.y
- @overlaysprite.color = self.color
- end
- if @refreshBitmap
- @refreshBitmap = false
- @overlaysprite.bitmap.clear if @overlaysprite.bitmap
- basecolor = Color.new(248,248,248)
- shadowcolor = Color.new(40,40,40)
- pbSetSystemFont(@overlaysprite.bitmap)
- textpos = []
- if $Trainer.partyplus>=1
- else
- # Draw Pokémon name
- textpos.push([@pokemon.name,96,16,0,basecolor,shadowcolor])
- if !@pokemon.egg?
- if !@text || @text.length==0
- # Draw HP numbers
- textpos.push([sprintf("% 3d /% 3d",@pokemon.hp,@pokemon.totalhp),224,60,1,basecolor,shadowcolor])
- # Draw HP bar
- if @pokemon.hp>0
- hpzone = 0
- hpzone = 1 if @pokemon.hp<=(@pokemon.totalhp/2).floor
- hpzone = 2 if @pokemon.hp<=(@pokemon.totalhp/4).floor
- hprect = Rect.new(0,hpzone*8,[@pokemon.hp*96/@pokemon.totalhp,2].max,8)
- @overlaysprite.bitmap.blt(128,52,@hpbar.bitmap,hprect)
- end
- # Draw status
- status = -1
- status = 6 if @pokemon.pokerusStage==1
- status = @pokemon.status-1 if @pokemon.status>0
- status = 5 if @pokemon.hp<=0
- if status>=0
- statusrect = Rect.new(0,16*status,44,16)
- @overlaysprite.bitmap.blt(78,68,@statuses.bitmap,statusrect)
- end
- end
- # Draw gender icon
- if @pokemon.isMale?
- textpos.push([_INTL("♂"),224,16,0,Color.new(0,112,248),Color.new(120,184,232)])
- elsif @pokemon.isFemale?
- textpos.push([_INTL("♀"),224,16,0,Color.new(232,32,16),Color.new(248,168,184)])
- end
- end
- pbDrawTextPositions(@overlaysprite.bitmap,textpos)
- # Draw level text
- if !@pokemon.egg?
- pbDrawImagePositions(@overlaysprite.bitmap,[[
- "Graphics/Pictures/Party/overlay_lv",20,70,0,0,22,14]])
- pbSetSmallFont(@overlaysprite.bitmap)
- pbDrawTextPositions(@overlaysprite.bitmap,[
- [@pokemon.level.to_s,42,62,0,basecolor,shadowcolor]
- ])
- end
- # Draw annotation text
- end
- if @text && @text.length>0
- pbSetSystemFont(@overlaysprite.bitmap)
- pbDrawTextPositions(@overlaysprite.bitmap,[
- [@text,96,58,0,basecolor,shadowcolor]
- ])
- end
- end
- @refreshing = false
- end
- def update
- super
- @panelbgsprite.update if @panelbgsprite && !@panelbgsprite.disposed?
- if $Trainer.partyplus>=1
- else
- @hpbgsprite.update if @hpbgsprite && !@hpbgsprite.disposed?
- end
- @ballsprite.update if @ballsprite && !@ballsprite.disposed?
- @pkmnsprite.update if @pkmnsprite && !@pkmnsprite.disposed?
- @helditemsprite.update if @helditemsprite && !@helditemsprite.disposed?
- end
- end
- #===============================================================================
- # Pokémon party visuals
- #===============================================================================
- class PokemonParty_Scene
- def pbStartScene(party,starthelptext,annotations=nil,multiselect=false)
- @sprites = {}
- @party = party
- @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z = 99999
- @multiselect = multiselect
- if $Trainer.partyplus==40
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/40 - Party/bg",@viewport)
- elsif $Trainer.partyplus==35
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/35 - Party/bg",@viewport)
- elsif $Trainer.partyplus==32
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/32 - Party/bg",@viewport)
- elsif $Trainer.partyplus==30
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/30 - Party/bg",@viewport)
- elsif $Trainer.partyplus==28
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/28 - Party/bg",@viewport)
- elsif $Trainer.partyplus==25
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/25 - Party/bg",@viewport)
- elsif $Trainer.partyplus==24
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/24 - Party/bg",@viewport)
- elsif $Trainer.partyplus==21
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/21 - Party/bg",@viewport)
- elsif $Trainer.partyplus==20
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/20 - Party/bg",@viewport)
- elsif $Trainer.partyplus==18
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/18 - Party/bg",@viewport)
- elsif $Trainer.partyplus==16
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/16 - Party/bg",@viewport)
- elsif $Trainer.partyplus==15
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/15 - Party/bg",@viewport)
- elsif $Trainer.partyplus==14
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/14 - Party/bg",@viewport)
- elsif $Trainer.partyplus==12
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/12 - Party/bg",@viewport)
- elsif $Trainer.partyplus==10
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/10 - Party/bg",@viewport)
- elsif $Trainer.partyplus==9
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/9 - Party/bg",@viewport)
- elsif $Trainer.partyplus==8
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/8 - Party/bg",@viewport)
- elsif $Trainer.partyplus==5
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/5 - Party/bg",@viewport)
- elsif $Trainer.partyplus==4
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/4 - Party/bg",@viewport)
- elsif $Trainer.partyplus==3
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/3 - Party/bg",@viewport)
- elsif $Trainer.partyplus==2
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/2 - Party/bg",@viewport)
- elsif $Trainer.partyplus==1
- addBackgroundPlane(@sprites,"partybg","Party/PartyPlus/1 - Party/bg",@viewport)
- else
- addBackgroundPlane(@sprites,"partybg","Party/bg",@viewport)
- end
- @sprites["messagebox"] = Window_AdvancedTextPokemon.new("")
- @sprites["messagebox"].viewport = @viewport
- @sprites["messagebox"].visible = false
- @sprites["messagebox"].letterbyletter = true
- pbBottomLeftLines(@sprites["messagebox"],2)
- @sprites["helpwindow"] = Window_UnformattedTextPokemon.new(starthelptext)
- @sprites["helpwindow"].viewport = @viewport
- @sprites["helpwindow"].visible = true
- pbBottomLeftLines(@sprites["helpwindow"],1)
- pbSetHelpText(starthelptext)
- # Add party Pokémon sprites
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- if @party[i]
- @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
- else
- @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
- end
- @sprites["pokemon#{i}"].text = annotations[i] if annotations
- end
- else
- for i in 0...6
- if @party[i]
- @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
- else
- @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
- end
- @sprites["pokemon#{i}"].text = annotations[i] if annotations
- end
- end
- if $Trainer.partyplus==40
- if @multiselect
- @sprites["pokemon40"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon41"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon40"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==35
- if @multiselect
- @sprites["pokemon35"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon36"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon35"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==32
- if @multiselect
- @sprites["pokemon32"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon33"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon32"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==30
- if @multiselect
- @sprites["pokemon30"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon31"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon30"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==28
- if @multiselect
- @sprites["pokemon28"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon29"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon28"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==25
- if @multiselect
- @sprites["pokemon25"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon26"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon25"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==24
- if @multiselect
- @sprites["pokemon24"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon25"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon24"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==21
- if @multiselect
- @sprites["pokemon21"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon22"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon21"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==20
- if @multiselect
- @sprites["pokemon20"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon21"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon20"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==18
- if @multiselect
- @sprites["pokemon18"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon19"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon18"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==16
- if @multiselect
- @sprites["pokemon16"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon17"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon16"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==15
- if @multiselect
- @sprites["pokemon15"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon16"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon15"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==14
- if @multiselect
- @sprites["pokemon14"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon15"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon14"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==12
- if @multiselect
- @sprites["pokemon12"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon13"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon12"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==10
- if @multiselect
- @sprites["pokemon10"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon11"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon10"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==9
- if @multiselect
- @sprites["pokemon9"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon10"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon9"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==8
- if @multiselect
- @sprites["pokemon8"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon9"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon8"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==5
- if @multiselect
- @sprites["pokemon5"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon6"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon5"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==4
- if @multiselect
- @sprites["pokemon4"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon5"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon4"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==3
- if @multiselect
- @sprites["pokemon3"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon4"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon3"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==2
- if @multiselect
- @sprites["pokemon2"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon3"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon2"] = PokemonPartyCancelSprite.new(@viewport)
- end
- elsif $Trainer.partyplus==1
- if @multiselect
- @sprites["pokemon1"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon2"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon1"] = PokemonPartyCancelSprite.new(@viewport)
- end
- else
- if @multiselect
- @sprites["pokemon6"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon7"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon6"] = PokemonPartyCancelSprite.new(@viewport)
- end
- end
- # Select first Pokémon
- @activecmd = 0
- @sprites["pokemon0"].selected = true
- pbFadeInAndShow(@sprites) { update }
- end
- def pbEndScene
- pbFadeOutAndHide(@sprites) { update }
- pbDisposeSpriteHash(@sprites)
- @viewport.dispose
- end
- def pbDisplay(text)
- @sprites["messagebox"].text = text
- @sprites["messagebox"].visible = true
- @sprites["helpwindow"].visible = false
- pbPlayDecisionSE
- loop do
- Graphics.update
- Input.update
- self.update
- if @sprites["messagebox"].busy?
- if Input.trigger?(Input::C)
- pbPlayDecisionSE if @sprites["messagebox"].pausing?
- @sprites["messagebox"].resume
- end
- else
- if Input.trigger?(Input::B) || Input.trigger?(Input::C)
- break
- end
- end
- end
- @sprites["messagebox"].visible = false
- @sprites["helpwindow"].visible = true
- end
- def pbDisplayConfirm(text)
- ret = -1
- @sprites["messagebox"].text = text
- @sprites["messagebox"].visible = true
- @sprites["helpwindow"].visible = false
- using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])) {
- cmdwindow.visible = false
- pbBottomRight(cmdwindow)
- cmdwindow.y -= @sprites["messagebox"].height
- cmdwindow.z = @viewport.z+1
- loop do
- Graphics.update
- Input.update
- cmdwindow.visible = true if !@sprites["messagebox"].busy?
- cmdwindow.update
- self.update
- if !@sprites["messagebox"].busy?
- if Input.trigger?(Input::B)
- ret = false
- break
- elsif Input.trigger?(Input::C) && @sprites["messagebox"].resume
- ret = (cmdwindow.index==0)
- break
- end
- end
- end
- }
- @sprites["messagebox"].visible = false
- @sprites["helpwindow"].visible = true
- return ret
- end
- def pbShowCommands(helptext,commands,index=0)
- ret = -1
- helpwindow = @sprites["helpwindow"]
- helpwindow.visible = true
- using(cmdwindow = Window_CommandPokemonColor.new(commands)) {
- cmdwindow.z = @viewport.z+1
- cmdwindow.index = index
- pbBottomRight(cmdwindow)
- helpwindow.resizeHeightToFit(helptext,Graphics.width-cmdwindow.width)
- helpwindow.text = helptext
- pbBottomLeft(helpwindow)
- loop do
- Graphics.update
- Input.update
- cmdwindow.update
- self.update
- if Input.trigger?(Input::B)
- pbPlayCancelSE
- ret = -1
- break
- elsif Input.trigger?(Input::C)
- pbPlayDecisionSE
- ret = cmdwindow.index
- break
- end
- end
- }
- return ret
- end
- def pbMessageFreeText(text,startMsg,maxlength) # Unused
- return Kernel.pbMessageFreeText(
- _INTL("Please enter a message (max. {1} characters).",maxlength),
- startMsg,false,maxlength,Graphics.width) { update }
- end
- def pbSetHelpText(helptext)
- helpwindow = @sprites["helpwindow"]
- pbBottomLeftLines(helpwindow,1)
- helpwindow.text = helptext
- helpwindow.width = 398
- helpwindow.visible = true
- end
- def pbAnnotate(annot)
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- @sprites["pokemon#{i}"].text = (annot) ? annot[i] : nil
- end
- else
- for i in 0...6
- @sprites["pokemon#{i}"].text = (annot) ? annot[i] : nil
- end
- end
- end
- def pbSelect(item)
- @activecmd = item
- if $Trainer.partyplus==40
- numsprites = (@multiselect) ? 42 : 41
- elsif $Trainer.partyplus==35
- numsprites = (@multiselect) ? 37 : 36
- elsif $Trainer.partyplus==32
- numsprites = (@multiselect) ? 33 : 32
- elsif $Trainer.partyplus==30
- numsprites = (@multiselect) ? 32 : 31
- elsif $Trainer.partyplus==28
- numsprites = (@multiselect) ? 30 : 29
- elsif $Trainer.partyplus==25
- numsprites = (@multiselect) ? 27 : 26
- elsif $Trainer.partyplus==24
- numsprites = (@multiselect) ? 26 : 25
- elsif $Trainer.partyplus==21
- numsprites = (@multiselect) ? 23 : 22
- elsif $Trainer.partyplus==20
- numsprites = (@multiselect) ? 22 : 21
- elsif $Trainer.partyplus==18
- numsprites = (@multiselect) ? 20 : 19
- elsif $Trainer.partyplus==16
- numsprites = (@multiselect) ? 18 : 17
- elsif $Trainer.partyplus==15
- numsprites = (@multiselect) ? 17 : 16
- elsif $Trainer.partyplus==14
- numsprites = (@multiselect) ? 16 : 15
- elsif $Trainer.partyplus==12
- numsprites = (@multiselect) ? 14 : 13
- elsif $Trainer.partyplus==10
- numsprites = (@multiselect) ? 12 : 11
- elsif $Trainer.partyplus==9
- numsprites = (@multiselect) ? 11 : 10
- elsif $Trainer.partyplus==8
- numsprites = (@multiselect) ? 10 : 9
- elsif $Trainer.partyplus==5
- numsprites = (@multiselect) ? 7 : 6
- elsif $Trainer.partyplus==4
- numsprites = (@multiselect) ? 6 : 5
- elsif $Trainer.partyplus==3
- numsprites = (@multiselect) ? 5 : 4
- elsif $Trainer.partyplus==2
- numsprites = (@multiselect) ? 4 : 3
- elsif $Trainer.partyplus==1
- numsprites = (@multiselect) ? 3 : 2
- else
- numsprites = (@multiselect) ? 8 : 7
- end
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- def pbPreSelect(item)
- @activecmd = item
- end
- def pbSwitchBegin(oldid,newid)
- oldsprite = @sprites["pokemon#{oldid}"]
- newsprite = @sprites["pokemon#{newid}"]
- 16.times do
- oldsprite.x += (oldid&1)==0 ? -16 : 16
- newsprite.x += (newid&1)==0 ? -16 : 16
- Graphics.update
- Input.update
- self.update
- end
- end
- def pbSwitchEnd(oldid,newid)
- oldsprite = @sprites["pokemon#{oldid}"]
- newsprite = @sprites["pokemon#{newid}"]
- oldsprite.pokemon = @party[oldid]
- newsprite.pokemon = @party[newid]
- 16.times do
- oldsprite.x -= (oldid&1)==0 ? -16 : 16
- newsprite.x -= (newid&1)==0 ? -16 : 16
- Graphics.update
- Input.update
- self.update
- end
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- else
- for i in 0...6
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- end
- pbRefresh
- end
- def pbClearSwitching
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- else
- for i in 0...6
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- end
- end
- def pbSummary(pkmnid)
- oldsprites = pbFadeOutAndHide(@sprites)
- scene = PokemonSummary_Scene.new
- screen = PokemonSummaryScreen.new(scene)
- screen.pbStartScreen(@party,pkmnid)
- pbFadeInAndShow(@sprites,oldsprites)
- end
- def pbChooseItem(bag)
- ret = 0
- pbFadeOutIn(99999){
- scene = PokemonBag_Scene.new
- screen = PokemonBagScreen.new(scene,bag)
- ret = screen.pbChooseItemScreen(Proc.new{|item| pbCanHoldItem?(item) })
- }
- return ret
- end
- def pbUseItem(bag,pokemon)
- ret = 0
- pbFadeOutIn(99999){
- scene = PokemonBag_Scene.new
- screen = PokemonBagScreen.new(scene,bag)
- ret = screen.pbChooseItemScreen(Proc.new{|item|
- next false if !pbCanUseOnPokemon?(item)
- if pbIsMachine?(item)
- move = pbGetMachine(item)
- next false if pokemon.hasMove?(move) || !pokemon.isCompatibleWithMove?(move)
- end
- next true
- })
- }
- return ret
- end
- def pbChoosePokemon(switching=false,initialsel=-1,canswitch=0)
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- @sprites["pokemon#{i}"].preselected = (switching && i==@activecmd)
- @sprites["pokemon#{i}"].switching = switching
- end
- else
- for i in 0...6
- @sprites["pokemon#{i}"].preselected = (switching && i==@activecmd)
- @sprites["pokemon#{i}"].switching = switching
- end
- end
- @activecmd = initialsel if initialsel>=0
- pbRefresh
- loop do
- Graphics.update
- Input.update
- self.update
- oldsel = @activecmd
- key = -1
- key = Input::DOWN if Input.repeat?(Input::DOWN)
- key = Input::RIGHT if Input.repeat?(Input::RIGHT)
- key = Input::LEFT if Input.repeat?(Input::LEFT)
- key = Input::UP if Input.repeat?(Input::UP)
- if key>=0
- @activecmd = pbChangeSelection(key,@activecmd)
- end
- if $Trainer.partyplus==40
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 42 : 41
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 41 : 40
- elsif $Trainer.partyplus==35
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 37 : 36
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 36 : 35
- elsif $Trainer.partyplus==32
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 34 : 33
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 33 : 32
- elsif $Trainer.partyplus==30
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 32 : 31
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 31 : 30
- elsif $Trainer.partyplus==28
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 30 : 29
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 29 : 28
- elsif $Trainer.partyplus==25
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 27 : 26
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 26 : 25
- elsif $Trainer.partyplus==24
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 26 : 25
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 25 : 24
- elsif $Trainer.partyplus==21
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 23 : 22
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 22 : 21
- elsif $Trainer.partyplus==20
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 22 : 21
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 21 : 20
- elsif $Trainer.partyplus==18
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 20 : 19
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 19 : 18
- elsif $Trainer.partyplus==16
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 18 : 17
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 17 : 16
- elsif $Trainer.partyplus==15
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 17 : 16
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 16 : 15
- elsif $Trainer.partyplus==14
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 16 : 15
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 15 : 14
- elsif $Trainer.partyplus==12
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 14 : 13
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 13 : 12
- elsif $Trainer.partyplus==10
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 12 : 11
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 11 : 10
- elsif $Trainer.partyplus==9
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 11 : 10
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 10 : 9
- elsif $Trainer.partyplus==8
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 10 : 9
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 9 : 8
- elsif $Trainer.partyplus==5
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 7 : 6
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 6 : 5
- elsif $Trainer.partyplus==4
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 6 : 5
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 5 : 4
- elsif $Trainer.partyplus==3
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 5 : 4
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 4 : 3
- elsif $Trainer.partyplus==2
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 4 : 3
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 3 : 2
- elsif $Trainer.partyplus==1
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 3 : 2
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 2 : 1
- else
- if @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 8 : 7
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 7 : 6
- end
- if Input.trigger?(Input::A) && canswitch==1 && @activecmd!=cancelsprite
- pbPlayDecisionSE
- return [1,@activecmd]
- elsif Input.trigger?(Input::A) && canswitch==2
- return -1
- elsif Input.trigger?(Input::B)
- return -1
- elsif Input.trigger?(Input::C)
- pbPlayDecisionSE
- return (@activecmd==cancelsprite) ? -1 : @activecmd
- end
- end
- end
- def pbChangeSelection(key,currentsel)
- if $Trainer.partyplus==40
- numsprites = (@multiselect) ? 42 : 41
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<40
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 40
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=40
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 8
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<40
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=33
- currentsel = 40
- else
- currentsel += 8
- currentsel = 40 if currentsel<40 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<40
- currentsel = 40
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==35
- numsprites = (@multiselect) ? 37 : 36
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<35
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 35
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=35
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 7
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<35
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=28
- currentsel = 35
- else
- currentsel += 7
- currentsel = 35 if currentsel<35 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<35
- currentsel = 35
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==32
- numsprites = (@multiselect) ? 34 : 33
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<32
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 32
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=32
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 6
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<32
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=25
- currentsel = 32
- else
- currentsel += 6
- currentsel = 32 if currentsel<32 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<32
- currentsel = 32
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==30
- numsprites = (@multiselect) ? 32 : 31
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<30
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 30
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=30
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 6
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<30
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=25
- currentsel = 30
- else
- currentsel += 6
- currentsel = 30 if currentsel<30 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<30
- currentsel = 30
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==28
- numsprites = (@multiselect) ? 30 : 29
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<28
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 28
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=28
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 7
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<28
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=22
- currentsel = 28
- else
- currentsel += 7
- currentsel = 28 if currentsel<28 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<28
- currentsel = 28
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==25
- numsprites = (@multiselect) ? 27 : 26
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<25
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 25
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=25
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 5
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<25
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=21
- currentsel = 25
- else
- currentsel += 5
- currentsel = 25 if currentsel<25 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<25
- currentsel = 25
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==24
- numsprites = (@multiselect) ? 26 : 25
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<24
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 24
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=24
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 6
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<24
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=19
- currentsel = 24
- else
- currentsel += 6
- currentsel = 24 if currentsel<24 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<24
- currentsel = 24
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==21
- numsprites = (@multiselect) ? 23 : 22
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<21
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 21
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=21
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 7
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<21
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=15
- currentsel = 21
- else
- currentsel += 7
- currentsel = 21 if currentsel<21 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<21
- currentsel = 21
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==20
- numsprites = (@multiselect) ? 22 : 21
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<20
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 20
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=20
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 5
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<20
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=16
- currentsel = 20
- else
- currentsel += 5
- currentsel = 20 if currentsel<20 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<20
- currentsel = 20
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==18
- numsprites = (@multiselect) ? 20 : 19
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<18
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 18
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=18
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 6
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<18
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=13
- currentsel = 18
- else
- currentsel += 6
- currentsel = 18 if currentsel<18 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<18
- currentsel = 18
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==16
- numsprites = (@multiselect) ? 18 : 17
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<16
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 16
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=16
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 4
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<16
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=13
- currentsel = 16
- else
- currentsel += 4
- currentsel = 16 if currentsel<16 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<16
- currentsel = 16
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==15
- numsprites = (@multiselect) ? 17 : 16
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<15
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 15
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=15
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 5
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<15
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=11
- currentsel = 15
- else
- currentsel += 5
- currentsel = 15 if currentsel<15 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<15
- currentsel = 15
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==14
- numsprites = (@multiselect) ? 16 : 15
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<14
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 14
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=14
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 7
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<14
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=8
- currentsel += 1
- else
- currentsel += 7
- currentsel = 14 if currentsel<14 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<14
- currentsel = 14
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==12
- numsprites = (@multiselect) ? 14 : 13
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<12
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 12
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=12
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 3
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<12
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=10
- currentsel += 1
- else
- currentsel += 3
- currentsel = 12 if currentsel<12 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<12
- currentsel = 12
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==10
- numsprites = (@multiselect) ? 12 : 11
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<10
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 10
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=10
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 2
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<10
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=9
- currentsel += 1
- else
- currentsel += 2
- currentsel = 10 if currentsel<10 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<10
- currentsel = 10
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==9
- numsprites = (@multiselect) ? 11 : 10
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<9
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 9
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=9
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 3
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<9
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=7
- currentsel += 1
- else
- currentsel += 3
- currentsel = 9 if currentsel<9 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<9
- currentsel = 9
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==8
- numsprites = (@multiselect) ? 10 : 9
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<8
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 8
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=8
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 2
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<8
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=7
- currentsel += 1
- else
- currentsel += 2
- currentsel = 8 if currentsel<8 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<8
- currentsel = 8
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==5
- numsprites = (@multiselect) ? 7 : 6
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<5
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 5
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=5
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<5
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=4
- currentsel += 1
- else
- currentsel += 1
- currentsel = 5 if currentsel<5 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<5
- currentsel = 5
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==4
- numsprites = (@multiselect) ? 6 : 5
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<4
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 4
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=4
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 2
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<4
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=3
- currentsel += 1
- else
- currentsel += 2
- currentsel = 4 if currentsel<4 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<4
- currentsel = 4
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==3
- numsprites = (@multiselect) ? 5 : 4
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<3
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 3
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=3
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<3
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=3
- currentsel += 1
- else
- currentsel += 1
- currentsel = 3 if currentsel<3 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<3
- currentsel = 3
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==2
- numsprites = (@multiselect) ? 4 : 3
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<2
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 2
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=2
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 2
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<2
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=2
- currentsel += 1
- else
- currentsel += 2
- currentsel = 2 if currentsel<2 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<2
- currentsel = 2
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- elsif $Trainer.partyplus==1
- numsprites = (@multiselect) ? 3 : 2
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<1
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 1
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=1
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<1
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=1
- currentsel += 1
- else
- currentsel += 1
- currentsel = 1 if currentsel<1 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<1
- currentsel = 1
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- else
- numsprites = (@multiselect) ? 8 : 7
- case key
- when Input::LEFT
- begin
- currentsel -= 1
- end while currentsel>0 && currentsel<@party.length && !@party[currentsel]
- if currentsel>=@party.length && currentsel<6
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::RIGHT
- begin
- currentsel += 1
- end while currentsel<@party.length && !@party[currentsel]
- if currentsel==@party.length
- currentsel = 6
- elsif currentsel==numsprites
- currentsel = 0
- end
- when Input::UP
- if currentsel>=6
- begin
- currentsel -= 1
- end while currentsel>0 && !@party[currentsel]
- else
- begin
- currentsel -= 2
- end while currentsel>0 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<6
- currentsel = @party.length-1
- end
- currentsel = numsprites-1 if currentsel<0
- when Input::DOWN
- if currentsel>=5
- currentsel += 1
- else
- currentsel += 2
- currentsel = 6 if currentsel<6 && !@party[currentsel]
- end
- if currentsel>=@party.length && currentsel<6
- currentsel = 6
- elsif currentsel>=numsprites
- currentsel = 0
- end
- end
- end
- return currentsel
- end
- def pbHardRefresh
- if $Trainer.partyplus>=1
- oldtext = []
- lastselected = -1
- for i in 0...$Trainer.partyplus
- oldtext.push(@sprites["pokemon#{i}"].text)
- lastselected = i if @sprites["pokemon#{i}"].selected
- @sprites["pokemon#{i}"].dispose
- end
- lastselected = @party.length-1 if lastselected>=@party.length
- lastselected = 0 if lastselected<0
- for i in 0...$Trainer.partyplus
- if @party[i]
- @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
- else
- @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
- end
- @sprites["pokemon#{i}"].text = oldtext[i]
- end
- pbSelect(lastselected)
- else
- oldtext = []
- lastselected = -1
- for i in 0...6
- oldtext.push(@sprites["pokemon#{i}"].text)
- lastselected = i if @sprites["pokemon#{i}"].selected
- @sprites["pokemon#{i}"].dispose
- end
- lastselected = @party.length-1 if lastselected>=@party.length
- lastselected = 0 if lastselected<0
- for i in 0...6
- if @party[i]
- @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport)
- else
- @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport)
- end
- @sprites["pokemon#{i}"].text = oldtext[i]
- end
- pbSelect(lastselected)
- end
- end
- def pbRefresh
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- sprite = @sprites["pokemon#{i}"]
- if sprite
- if sprite.is_a?(PokemonPartyPanel)
- sprite.pokemon = sprite.pokemon
- else
- sprite.refresh
- end
- end
- end
- else
- for i in 0...6
- sprite = @sprites["pokemon#{i}"]
- if sprite
- if sprite.is_a?(PokemonPartyPanel)
- sprite.pokemon = sprite.pokemon
- else
- sprite.refresh
- end
- end
- end
- end
- end
- def pbRefreshSingle(i)
- sprite = @sprites["pokemon#{i}"]
- if sprite
- if sprite.is_a?(PokemonPartyPanel)
- sprite.pokemon = sprite.pokemon
- else
- sprite.refresh
- end
- end
- end
- def update
- pbUpdateSpriteHash(@sprites)
- end
- end
- ################################################################################
- # Storage Scene #
- ################################################################################
- #===============================================================================
- # Party pop-up panel
- #===============================================================================
- class PokemonBoxPartySprite < SpriteWrapper
- def initialize(party,viewport=nil)
- super(viewport)
- @party = party
- if $Trainer.partyplus==40
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_40_party")
- elsif $Trainer.partyplus==35
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_35_party")
- elsif $Trainer.partyplus==32
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_32_party")
- elsif $Trainer.partyplus==30
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_30_party")
- elsif $Trainer.partyplus==28
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_28_party")
- elsif $Trainer.partyplus==25
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_25_party")
- elsif $Trainer.partyplus==24
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_24_party")
- elsif $Trainer.partyplus==21
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_21_party")
- elsif $Trainer.partyplus==20
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_20_party")
- elsif $Trainer.partyplus==18
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_18_party")
- elsif $Trainer.partyplus==16
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_16_party")
- elsif $Trainer.partyplus==15
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_15_party")
- elsif $Trainer.partyplus==14
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_14_party")
- elsif $Trainer.partyplus==12
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_12_party")
- elsif $Trainer.partyplus==10
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_10_party")
- elsif $Trainer.partyplus==9
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_9_party")
- elsif $Trainer.partyplus==8
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_8_party")
- elsif $Trainer.partyplus==5
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_5_party")
- elsif $Trainer.partyplus==4
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_4_party")
- elsif $Trainer.partyplus==3
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_3_party")
- elsif $Trainer.partyplus==2
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_2_party")
- elsif $Trainer.partyplus==1
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_1_party")
- else
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_party")
- end
- @pokemonsprites = []
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- @pokemonsprites[i] = nil
- pokemon = @party[i]
- if pokemon
- @pokemonsprites[i] = PokemonBoxIcon.new(pokemon,viewport)
- end
- end
- else
- for i in 0...6
- @pokemonsprites[i] = nil
- pokemon = @party[i]
- if pokemon
- @pokemonsprites[i] = PokemonBoxIcon.new(pokemon,viewport)
- end
- end
- end
- if $Trainer.partyplus==40
- @contents = BitmapWrapper.new(508,356)
- self.bitmap = @contents
- self.x = 512-508
- self.y = Graphics.height-356
- elsif $Trainer.partyplus==35
- @contents = BitmapWrapper.new(476,350)
- self.bitmap = @contents
- self.x = 512-476
- self.y = Graphics.height-350
- elsif $Trainer.partyplus==32
- @contents = BitmapWrapper.new(508,306)
- self.bitmap = @contents
- self.x = 512-508
- self.y = Graphics.height-306
- elsif $Trainer.partyplus==30
- @contents = BitmapWrapper.new(412,350)
- self.bitmap = @contents
- self.x = 512-412
- self.y = Graphics.height-350
- elsif $Trainer.partyplus==28
- @contents = BitmapWrapper.new(476,302)
- self.bitmap = @contents
- self.x = 512-476
- self.y = Graphics.height-302
- elsif $Trainer.partyplus==25
- @contents = BitmapWrapper.new(348,350)
- self.bitmap = @contents
- self.x = 512-348
- self.y = Graphics.height-350
- elsif $Trainer.partyplus==24
- @contents = BitmapWrapper.new(412,302)
- self.bitmap = @contents
- self.x = 512-412
- self.y = Graphics.height-302
- elsif $Trainer.partyplus==21
- @contents = BitmapWrapper.new(476,254)
- self.bitmap = @contents
- self.x = 512-476
- self.y = Graphics.height-254
- elsif $Trainer.partyplus==20
- @contents = BitmapWrapper.new(348,302)
- self.bitmap = @contents
- self.x = 512-348
- self.y = Graphics.height-302
- elsif $Trainer.partyplus==18
- @contents = BitmapWrapper.new(412,254)
- self.bitmap = @contents
- self.x = 512-412
- self.y = Graphics.height-254
- elsif $Trainer.partyplus==16
- @contents = BitmapWrapper.new(284,302)
- self.bitmap = @contents
- self.x = 512-284
- self.y = Graphics.height-302
- elsif $Trainer.partyplus==15
- @contents = BitmapWrapper.new(348,254)
- self.bitmap = @contents
- self.x = 512-348
- self.y = Graphics.height-254
- elsif $Trainer.partyplus==14
- @contents = BitmapWrapper.new(476,206)
- self.bitmap = @contents
- self.x = 512-476
- self.y = Graphics.height-206
- elsif $Trainer.partyplus==12
- @contents = BitmapWrapper.new(220,302)
- self.bitmap = @contents
- self.x = 512-220
- self.y = Graphics.height-302
- elsif $Trainer.partyplus==10
- @contents = BitmapWrapper.new(172,350)
- self.bitmap = @contents
- self.x = 512-172
- self.y = Graphics.height-350
- elsif $Trainer.partyplus==9
- @contents = BitmapWrapper.new(222,254)
- self.bitmap = @contents
- self.x = 512-222
- self.y = Graphics.height-254
- elsif $Trainer.partyplus==8
- @contents = BitmapWrapper.new(172,302)
- self.bitmap = @contents
- self.x = 512-172
- self.y = Graphics.height-302
- elsif $Trainer.partyplus==5
- @contents = BitmapWrapper.new(172,334)
- self.bitmap = @contents
- self.x = 512-172
- self.y = Graphics.height-334
- elsif $Trainer.partyplus==4
- @contents = BitmapWrapper.new(172,206)
- self.bitmap = @contents
- self.x = 512-172
- self.y = Graphics.height-206
- elsif $Trainer.partyplus==3
- @contents = BitmapWrapper.new(172,238)
- self.bitmap = @contents
- self.x = 512-172
- self.y = Graphics.height-238
- elsif $Trainer.partyplus==2
- @contents = BitmapWrapper.new(172,158)
- self.bitmap = @contents
- self.x = 512-172
- self.y = Graphics.height-158
- elsif $Trainer.partyplus==1
- @contents = BitmapWrapper.new(172,141)
- self.bitmap = @contents
- self.x = 512-172
- self.y = Graphics.height-141
- else
- @contents = BitmapWrapper.new(172,352)
- self.bitmap = @contents
- self.x = 182
- self.y = Graphics.height-352
- end
- pbSetSystemFont(self.bitmap)
- refresh
- end
- def dispose
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- @pokemonsprites[i].dispose if @pokemonsprites[i]
- end
- else
- for i in 0...6
- @pokemonsprites[i].dispose if @pokemonsprites[i]
- end
- end
- @boxbitmap.dispose
- @contents.dispose
- super
- end
- def x=(value)
- super
- refresh
- end
- def y=(value)
- super
- refresh
- end
- def color=(value)
- super
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color,value)
- end
- end
- else
- for i in 0...6
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color,value)
- end
- end
- end
- end
- def visible=(value)
- super
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].visible = value
- end
- end
- else
- for i in 0...6
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].visible = value
- end
- end
- end
- end
- def getPokemon(index)
- return @pokemonsprites[index]
- end
- def setPokemon(index,sprite)
- @pokemonsprites[index] = sprite
- @pokemonsprites.compact!
- refresh
- end
- def grabPokemon(index,arrow)
- sprite = @pokemonsprites[index]
- if sprite
- arrow.grab(sprite)
- @pokemonsprites[index] = nil
- @pokemonsprites.compact!
- refresh
- end
- end
- def deletePokemon(index)
- @pokemonsprites[index].dispose
- @pokemonsprites[index] = nil
- @pokemonsprites.compact!
- refresh
- end
- def refresh
- if $Trainer.partyplus==40
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,508,356))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),254,312,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [12,72,132,192,252,312,372,432,12,72,132,192,252,312,372,432,12,72,132,192,252,312,372,432,12,72,132,192,252,312,372,432,12,72,132,192,252,312,372,432]
- yvalues = [18,32,18,32,18,32,18,32,68,82,68,82,68,82,68,82,118,132,118,132,118,132,118,132,168,182,168,182,168,182,168,182,218,232,218,232,218,232,218,232]
- elsif $Trainer.partyplus==35
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,476,350))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),238,306,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,334,398,14,78,142,206,270,334,398,14,78,142,206,270,334,398,14,78,142,206,270,334,398,14,78,142,206,270,334,398,]
- yvalues = [34,18,34,18,34,18,34,82,66,82,66,82,66,82,130,114,130,114,130,114,114,162,178,162,178,162,178,162,210,226,210,226,210,226,210]
- elsif $Trainer.partyplus==32
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,508,306))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),254,262,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [12,72,132,192,252,312,372,432,12,72,132,192,252,312,372,432,12,72,132,192,252,312,372,432,12,72,132,192,252,312,372,432]
- yvalues = [18,32,18,32,18,32,18,32,68,82,68,82,68,82,68,82,118,132,118,132,118,132,118,132,168,182,168,182,168,182,168,282]
- elsif $Trainer.partyplus==30
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,412,350))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),206,306,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,334,14,78,142,206,270,334,14,78,142,206,270,334,14,78,142,206,270,334,14,78,142,206,270,334]
- yvalues = [18,34,18,34,18,34,66,82,66,82,66,82,114,130,114,130,114,130,178,162,178,162,178,162,226,210,226,210,226,210]
- elsif $Trainer.partyplus==28
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,476,302))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),238,258,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,334,398,14,78,142,206,270,334,398,14,78,142,206,270,334,398,14,78,142,206,270,334,398]
- yvalues = [18,34,18,34,18,34,18,66,82,66,82,66,82,66,114,130,114,130,114,130,114,178,162,178,162,178,162,178]
- elsif $Trainer.partyplus==25
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,348,350))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),174,306,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,14,78,142,206,270,14,78,142,206,270,14,78,142,206,270,14,78,142,206,270]
- yvalues = [34,18,34,18,34,82,66,82,66,82,130,114,130,114,130,162,178,162,178,162,210,226,210,226,210]
- elsif $Trainer.partyplus==24
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,412,302))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),206,258,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,334,14,78,142,206,270,334,14,78,142,206,270,334,14,78,142,206,270,334]
- yvalues = [18,34,18,34,18,34,66,82,66,82,66,82,114,130,114,130,114,130,162,178,162,178,162,178]
- elsif $Trainer.partyplus==21
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,476,254))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),238,210,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,334,398,14,78,142,206,270,334,398,14,78,142,206,270,334,398]
- yvalues = [34,18,34,18,34,18,34,82,66,82,66,82,66,82,130,114,130,114,130,114,130]
- elsif $Trainer.partyplus==20
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,348,302))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),174,258,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,14,78,142,206,270,14,78,142,206,270,14,78,142,206,270]
- yvalues = [34,18,34,18,34,82,66,82,66,82,130,114,130,114,130,162,178,162,178,162]
- elsif $Trainer.partyplus==18
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,412,254))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),206,210,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,334,14,78,142,206,270,334,14,78,142,206,270,334]
- yvalues = [18,34,18,34,18,34,66,82,66,82,66,82,114,130,114,130,114,130]
- elsif $Trainer.partyplus==16
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,284,302))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),142,258,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,14,78,142,206,14,78,142,206,14,78,142,206,]
- yvalues = [18,34,18,34,66,82,66,82,114,130,114,130,162,178,162,178]
- elsif $Trainer.partyplus==15
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,348,254))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),174,210,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,14,78,142,206,270,14,78,142,206,270]
- yvalues = [34,18,34,18,34,82,66,82,66,82,130,114,130,114,130]
- elsif $Trainer.partyplus==14
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,476,206))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),238,162,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,206,270,334,398,14,78,142,206,270,334,398]
- yvalues = [34,18,34,18,34,18,34,82,66,82,66,82,66,82]
- elsif $Trainer.partyplus==12
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,220,302))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),110,258,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,14,78,142,14,78,142,14,78,142]
- yvalues = [34,18,34,82,66,82,130,114,130,178,162,178]
- elsif $Trainer.partyplus==10
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,350))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,306,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [22,86,22,86,22,86,22,86,22,86]
- yvalues = [18,34,66,82,114,130,162,178,210,226]
- elsif $Trainer.partyplus==9
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,222,254))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),110,210,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [14,78,142,14,78,142,14,78,142]
- yvalues = [34,18,34,82,66,82,130,114,130]
- elsif $Trainer.partyplus==8
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,302))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,258,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [22,86,22,86,22,86,22,86]
- yvalues = [18,34,66,82,114,130,162,178]
- elsif $Trainer.partyplus==5
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,334))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,290,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [54,54,54,54,54]
- yvalues = [18,66,114,162,210]
- elsif $Trainer.partyplus==4
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,206))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,162,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [22,86,22,86]
- yvalues = [18,34,66,82]
- elsif $Trainer.partyplus==3
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,238))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,194,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [54,54,54]
- yvalues = [18,66,114]
- elsif $Trainer.partyplus==2
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,158))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,114,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [22,86]
- yvalues = [18,34]
- elsif $Trainer.partyplus==1
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,141))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,97,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [54]
- yvalues = [18]
- else
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,352))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,242,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [18,90,18,90,18,90]
- yvalues = [2,18,66,82,130,146]
- end
- if $Trainer.partyplus>=1
- for j in 0...$Trainer.partyplus
- @pokemonsprites[j] = nil if @pokemonsprites[j] && @pokemonsprites[j].disposed?
- end
- @pokemonsprites.compact!
- for j in 0...$Trainer.partyplus
- sprite = @pokemonsprites[j]
- if sprite && !sprite.disposed?
- sprite.viewport = self.viewport
- sprite.x = self.x+xvalues[j]
- sprite.y = self.y+yvalues[j]
- sprite.z = 0
- end
- end
- else
- for j in 0...6
- @pokemonsprites[j] = nil if @pokemonsprites[j] && @pokemonsprites[j].disposed?
- end
- @pokemonsprites.compact!
- for j in 0...6
- sprite = @pokemonsprites[j]
- if sprite && !sprite.disposed?
- sprite.viewport = self.viewport
- sprite.x = self.x+xvalues[j]
- sprite.y = self.y+yvalues[j]
- sprite.z = 0
- end
- end
- end
- end
- def update
- super
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- @pokemonsprites[i].update if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- end
- else
- for i in 0...6
- @pokemonsprites[i].update if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- end
- end
- end
- end
- #===============================================================================
- # Pokémon storage visuals
- #===============================================================================
- class PokemonStorageScene
- attr_reader :quickswap
- def initialize
- @command = 1
- end
- def pbStartBox(screen,command)
- @screen = screen
- @storage = screen.storage
- @bgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @bgviewport.z = 99999
- @boxviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @boxviewport.z = 99999
- @boxsidesviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @boxsidesviewport.z = 99999
- @arrowviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @arrowviewport.z = 99999
- @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z = 99999
- @selection = 0
- @quickswap = false
- @sprites = {}
- @choseFromParty = false
- @command = command
- addBackgroundPlane(@sprites,"background","Storage/bg",@bgviewport)
- @sprites["box"] = PokemonBoxSprite.new(@storage,@storage.currentBox,@boxviewport)
- @sprites["boxsides"] = IconSprite.new(0,0,@boxsidesviewport)
- @sprites["boxsides"].setBitmap("Graphics/Pictures/Storage/overlay_main")
- @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@boxsidesviewport)
- pbSetSystemFont(@sprites["overlay"].bitmap)
- @sprites["pokemon"] = AutoMosaicPokemonSprite.new(@boxsidesviewport)
- @sprites["pokemon"].setOffset(PictureOrigin::Center)
- @sprites["pokemon"].x = 90
- @sprites["pokemon"].y = 134
- @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party,@boxsidesviewport)
- if command!=2 # Drop down tab only on Deposit
- if $Trainer.partyplus==40
- @sprites["boxparty"].x = 512-508
- elsif $Trainer.partyplus==35
- @sprites["boxparty"].x = 512-476
- elsif $Trainer.partyplus==32
- @sprites["boxparty"].x = 512-508
- elsif $Trainer.partyplus==30
- @sprites["boxparty"].x = 512-412
- elsif $Trainer.partyplus==28
- @sprites["boxparty"].x = 512-476
- elsif $Trainer.partyplus==25
- @sprites["boxparty"].x = 512-348
- elsif $Trainer.partyplus==24
- @sprites["boxparty"].x = 512-412
- elsif $Trainer.partyplus==21
- @sprites["boxparty"].x = 512-476
- elsif $Trainer.partyplus==20
- @sprites["boxparty"].x = 512-348
- elsif $Trainer.partyplus==18
- @sprites["boxparty"].x = 512-412
- elsif $Trainer.partyplus==16
- @sprites["boxparty"].x = 512-284
- elsif $Trainer.partyplus==15
- @sprites["boxparty"].x = 512-348
- elsif $Trainer.partyplus==14
- @sprites["boxparty"].x = 512-476
- elsif $Trainer.partyplus==12
- @sprites["boxparty"].x = 512-220
- elsif $Trainer.partyplus==10
- @sprites["boxparty"].x = 512-172
- elsif $Trainer.partyplus==9
- @sprites["boxparty"].x = 512-222
- elsif $Trainer.partyplus==8
- @sprites["boxparty"].x = 512-172
- elsif $Trainer.partyplus==5
- @sprites["boxparty"].x = 512-172
- elsif $Trainer.partyplus==4
- @sprites["boxparty"].x = 512-172
- elsif $Trainer.partyplus==3
- @sprites["boxparty"].x = 512-172
- elsif $Trainer.partyplus==2
- @sprites["boxparty"].x = 512-172
- elsif $Trainer.partyplus==1
- @sprites["boxparty"].x = 512-172
- else
- @sprites["boxparty"].x = 182
- end
- @sprites["boxparty"].y = Graphics.height
- end
- @markingbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/markings")
- @sprites["markingbg"] = IconSprite.new(292,68,@boxsidesviewport)
- @sprites["markingbg"].setBitmap("Graphics/Pictures/Storage/overlay_marking")
- @sprites["markingbg"].visible = false
- @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@boxsidesviewport)
- @sprites["markingoverlay"].visible = false
- pbSetSystemFont(@sprites["markingoverlay"].bitmap)
- @sprites["arrow"] = PokemonBoxArrow.new(@arrowviewport)
- @sprites["arrow"].z += 1
- if command!=2
- pbSetArrow(@sprites["arrow"],@selection)
- pbUpdateOverlay(@selection)
- pbSetMosaic(@selection)
- else
- pbPartySetArrow(@sprites["arrow"],@selection)
- pbUpdateOverlay(@selection,@storage.party)
- pbSetMosaic(@selection)
- end
- pbFadeInAndShow(@sprites)
- end
- def pbCloseBox
- pbFadeOutAndHide(@sprites)
- pbDisposeSpriteHash(@sprites)
- @markingbitmap.dispose if @markingbitmap
- @boxviewport.dispose
- @boxsidesviewport.dispose
- @arrowviewport.dispose
- end
- def pbDisplay(message)
- msgwindow = Window_UnformattedTextPokemon.newWithSize("",180,0,Graphics.width-180,32)
- msgwindow.viewport = @viewport
- msgwindow.visible = true
- msgwindow.letterbyletter = false
- msgwindow.resizeHeightToFit(message,Graphics.width-180)
- msgwindow.text = message
- pbBottomRight(msgwindow)
- loop do
- Graphics.update
- Input.update
- if Input.trigger?(Input::B) || Input.trigger?(Input::C)
- break
- end
- msgwindow.update
- self.update
- end
- msgwindow.dispose
- Input.update
- end
- def pbShowCommands(message,commands,index=0)
- ret = 0
- msgwindow = Window_UnformattedTextPokemon.newWithSize("",180,0,Graphics.width-180,32)
- msgwindow.viewport = @viewport
- msgwindow.visible = true
- msgwindow.letterbyletter = false
- msgwindow.text = message
- msgwindow.resizeHeightToFit(message,Graphics.width-180)
- pbBottomRight(msgwindow)
- cmdwindow = Window_CommandPokemon.new(commands)
- cmdwindow.viewport = @viewport
- cmdwindow.visible = true
- cmdwindow.resizeToFit(cmdwindow.commands)
- cmdwindow.height = Graphics.height-msgwindow.height if cmdwindow.height>Graphics.height-msgwindow.height
- pbBottomRight(cmdwindow)
- cmdwindow.y -= msgwindow.height
- cmdwindow.index = index
- loop do
- Graphics.update
- Input.update
- msgwindow.update
- cmdwindow.update
- if Input.trigger?(Input::B)
- ret = -1
- break
- elsif Input.trigger?(Input::C)
- ret = cmdwindow.index
- break
- end
- self.update
- end
- msgwindow.dispose
- cmdwindow.dispose
- Input.update
- return ret
- end
- def pbSetArrow(arrow,selection)
- case selection
- when -1, -4, -5 # Box name, move left, move right
- arrow.x = 157*2
- arrow.y = -12*2
- when -2 # Party Pokémon
- arrow.x = 119*2
- arrow.y = 139*2
- when -3 # Close Box
- arrow.x = 207*2
- arrow.y = 139*2
- else
- arrow.x = (97+24*(selection%6))*2
- arrow.y = (8+24*(selection/6))*2
- end
- end
- def pbChangeSelection(key,selection)
- case key
- when Input::UP
- if selection==-1 # Box name
- selection = -2
- elsif selection==-2 # Party
- selection = 25
- elsif selection==-3 # Close Box
- selection = 28
- else
- selection -= 6
- selection = -1 if selection<0
- end
- when Input::DOWN
- if selection==-1 # Box name
- selection = 2
- elsif selection==-2 # Party
- selection = -1
- elsif selection==-3 # Close Box
- selection = -1
- else
- selection += 6
- selection = -2 if selection==30 || selection==31 || selection==32
- selection = -3 if selection==33 || selection==34 || selection==35
- end
- when Input::LEFT
- if selection==-1 # Box name
- selection = -4 # Move to previous box
- elsif selection==-2
- selection = -3
- elsif selection==-3
- selection = -2
- else
- selection -= 1
- selection += 6 if selection==-1 || selection%6==5
- end
- when Input::RIGHT
- if selection==-1 # Box name
- selection = -5 # Move to next box
- elsif selection==-2
- selection = -3
- elsif selection==-3
- selection = -2
- else
- selection += 1
- selection -= 6 if selection%6==0
- end
- end
- return selection
- end
- def pbPartySetArrow(arrow,selection)
- if selection>=0
- if $Trainer.partyplus==40
- xvalues = [16,76,136,196,256,316,376,436,16,76,136,196,256,316,376,436,16,76,136,196,256,316,376,436,16,76,136,196,256,316,376,436,16,76,136,196,256,316,376,436,226]
- yvalues = [14,28,14,28,14,28,14,28,64,78,64,78,64,78,64,78,114,128,114,128,114,128,114,128,164,178,164,178,164,178,164,178,214,228,214,228,214,228,214,228,280]
- elsif $Trainer.partyplus==35
- xvalues = [50,114,178,242,306,370,434,50,114,178,242,306,370,434,50,114,178,242,306,370,434,50,114,178,242,306,370,434,50,114,178,242,306,370,434,242]
- yvalues = [36,20,36,20,36,20,36,84,68,84,68,84,68,84,132,116,132,116,132,116,132,164,180,164,180,164,180,164,228,212,228,212,228,212,228,280]
- elsif $Trainer.partyplus==32
- xvalues = [16,76,136,196,256,316,376,436,16,76,136,196,256,316,376,436,16,76,136,196,256,316,376,436,16,76,136,196,256,316,376,436,226]
- yvalues = [64,78,64,78,64,78,64,78,114,128,114,128,114,128,114,128,164,178,164,178,164,178,164,178,214,228,214,228,214,228,214,228,280]
- elsif $Trainer.partyplus==30
- xvalues = [114,178,242,306,370,434,114,178,242,306,370,434,114,178,242,306,370,434,114,178,242,306,370,434,114,178,242,306,370,434,279]
- yvalues = [20,36,20,36,20,36,68,84,68,84,68,84,116,132,116,132,116,132,164,180,164,180,164,180,212,228,212,228,212,228,280]
- elsif $Trainer.partyplus==28
- xvalues = [50,114,178,242,306,370,434,50,114,178,242,306,370,434,50,114,178,242,306,370,434,50,114,178,242,306,370,434,242]
- yvalues = [68,84,68,84,68,84,68,116,132,116,132,116,132,116,164,180,164,180,164,180,164,212,228,212,228,212,228,212,280]
- elsif $Trainer.partyplus==25
- xvalues = [178,242,306,370,434,178,242,306,370,434,178,242,306,370,434,178,242,306,370,434,178,242,306,370,434,308]
- yvalues = [36,20,36,20,36,84,68,84,68,84,132,116,132,116,132,180,164,180,164,180,228,212,228,212,228,280]
- elsif $Trainer.partyplus==24
- xvalues = [114,178,242,306,370,434,114,178,242,306,370,434,114,178,242,306,370,434,114,178,242,306,370,434,274]
- yvalues = [68,84,68,84,68,84,116,132,116,132,116,132,164,180,164,180,164,180,212,228,212,228,212,228,280]
- elsif $Trainer.partyplus==21
- xvalues = [50,114,178,242,306,370,434,50,114,178,242,306,370,434,50,114,178,242,306,370,434,242]
- yvalues = [132,116,132,116,132,116,132,180,164,180,164,180,164,180,228,212,228,212,228,212,228,280]
- elsif $Trainer.partyplus==20
- xvalues = [178,242,306,370,434,178,242,306,370,434,178,242,306,370,434,178,242,306,370,434,308]
- yvalues = [84,68,84,68,84,132,116,132,116,132,180,164,180,164,180,228,212,228,212,228,280]
- elsif $Trainer.partyplus==18
- xvalues = [114,178,242,306,370,434,114,178,242,306,370,434,114,178,242,306,370,434,274]
- yvalues = [116,132,116,132,116,132,164,180,164,180,164,180,212,228,212,228,212,228,280]
- elsif $Trainer.partyplus==16
- xvalues = [242,306,370,434,242,306,370,434,242,306,370,434,242,306,370,434,338]
- yvalues = [68,84,68,84,116,132,116,132,164,180,164,180,212,228,212,228,280]
- elsif $Trainer.partyplus==15
- xvalues = [178,242,306,370,434,178,242,306,370,434,178,242,306,370,434,308]
- yvalues = [132,116,132,116,132,180,164,180,164,180,228,212,228,212,228,280]
- elsif $Trainer.partyplus==14
- xvalues = [50,114,178,242,306,370,434,50,114,178,242,306,370,434,242]
- yvalues = [180,164,180,164,180,164,180,228,212,228,212,228,212,228,280]
- elsif $Trainer.partyplus==12
- xvalues = [306,370,434,306,370,434,306,370,434,306,370,434,370]
- yvalues = [84,68,84,132,116,132,180,164,180,228,212,228,280]
- elsif $Trainer.partyplus==10
- xvalues = [362,426,362,426,362,426,362,426,362,426,394]
- yvalues = [20,36,68,84,116,132,164,180,212,228,280]
- elsif $Trainer.partyplus==9
- xvalues = [304,368,432,304,368,432,304,368,432,370]
- yvalues = [132,116,132,180,164,180,228,212,228,280]
- elsif $Trainer.partyplus==8
- xvalues = [362,426,362,426,362,426,362,426,394]
- yvalues = [68,84,116,132,164,180,212,228,280]
- elsif $Trainer.partyplus==5
- xvalues = [394,394,394,394,394,394]
- yvalues = [36,84,132,180,228,280]
- elsif $Trainer.partyplus==4
- xvalues = [362,426,362,426,394]
- yvalues = [164,180,212,228,280]
- elsif $Trainer.partyplus==3
- xvalues = [394,394,394,394]
- yvalues = [132,180,228,280]
- elsif $Trainer.partyplus==2
- xvalues = [362,426,394]
- yvalues = [212,228,280]
- elsif $Trainer.partyplus==1
- xvalues = [394,394]
- yvalues = [228,280]
- else
- xvalues = [200,272,200,272,200,272,236]
- yvalues = [2,18,66,82,130,146,220]
- end
- arrow.angle = 0
- arrow.mirror = false
- arrow.ox = 0
- arrow.oy = 0
- arrow.x = xvalues[selection]
- arrow.y = yvalues[selection]
- end
- end
- def pbPartyChangeSelection(key,selection)
- if $Trainer.partyplus==40
- case key
- when Input::LEFT
- selection -= 1
- selection = 40 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>40
- when Input::UP
- if selection==40
- selection = 39
- else
- selection -= 8
- selection = 40 if selection<0
- end
- when Input::DOWN
- if selection==40
- selection = 0
- else
- selection += 8
- selection = 40 if selection>40
- end
- end
- elsif $Trainer.partyplus==35
- case key
- when Input::LEFT
- selection -= 1
- selection = 35 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>35
- when Input::UP
- if selection==35
- selection = 34
- else
- selection -= 7
- selection = 35 if selection<0
- end
- when Input::DOWN
- if selection==35
- selection = 0
- else
- selection += 7
- selection = 35 if selection>35
- end
- end
- elsif $Trainer.partyplus==32
- case key
- when Input::LEFT
- selection -= 1
- selection = 32 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>32
- when Input::UP
- if selection==32
- selection = 31
- else
- selection -= 8
- selection = 32 if selection<0
- end
- when Input::DOWN
- if selection==32
- selection = 0
- else
- selection += 8
- selection = 32 if selection>32
- end
- end
- elsif $Trainer.partyplus==30
- case key
- when Input::LEFT
- selection -= 1
- selection = 30 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>30
- when Input::UP
- if selection==30
- selection = 29
- else
- selection -= 6
- selection = 30 if selection<0
- end
- when Input::DOWN
- if selection==30
- selection = 0
- else
- selection += 6
- selection = 30 if selection>30
- end
- end
- elsif $Trainer.partyplus==28
- case key
- when Input::LEFT
- selection -= 1
- selection = 28 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>28
- when Input::UP
- if selection==28
- selection = 27
- else
- selection -= 7
- selection = 28 if selection<0
- end
- when Input::DOWN
- if selection==28
- selection = 0
- else
- selection += 7
- selection = 28 if selection>28
- end
- end
- elsif $Trainer.partyplus==25
- case key
- when Input::LEFT
- selection -= 1
- selection = 25 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>25
- when Input::UP
- if selection==25
- selection = 24
- else
- selection -= 5
- selection = 25 if selection<0
- end
- when Input::DOWN
- if selection==25
- selection = 0
- else
- selection += 5
- selection = 25 if selection>25
- end
- end
- elsif $Trainer.partyplus==24
- case key
- when Input::LEFT
- selection -= 1
- selection = 24 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>24
- when Input::UP
- if selection==24
- selection = 23
- else
- selection -= 6
- selection = 24 if selection<0
- end
- when Input::DOWN
- if selection==24
- selection = 0
- else
- selection += 6
- selection = 24 if selection>24
- end
- end
- elsif $Trainer.partyplus==21
- case key
- when Input::LEFT
- selection -= 1
- selection = 21 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>21
- when Input::UP
- if selection==21
- selection = 20
- else
- selection -= 7
- selection = 21 if selection<0
- end
- when Input::DOWN
- if selection==21
- selection = 0
- else
- selection += 7
- selection = 21 if selection>21
- end
- end
- elsif $Trainer.partyplus==20
- case key
- when Input::LEFT
- selection -= 1
- selection = 20 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>20
- when Input::UP
- if selection==20
- selection = 19
- else
- selection -= 5
- selection = 20 if selection<0
- end
- when Input::DOWN
- if selection==20
- selection = 0
- else
- selection += 5
- selection = 20 if selection>20
- end
- end
- elsif $Trainer.partyplus==18
- case key
- when Input::LEFT
- selection -= 1
- selection = 18 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>18
- when Input::UP
- if selection==18
- selection = 17
- else
- selection -= 6
- selection = 18 if selection<0
- end
- when Input::DOWN
- if selection==18
- selection = 0
- else
- selection += 6
- selection = 18 if selection>18
- end
- end
- elsif $Trainer.partyplus==16
- case key
- when Input::LEFT
- selection -= 1
- selection = 16 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>16
- when Input::UP
- if selection==16
- selection = 15
- else
- selection -= 4
- selection = 16 if selection<0
- end
- when Input::DOWN
- if selection==16
- selection = 0
- else
- selection += 4
- selection = 16 if selection>16
- end
- end
- elsif $Trainer.partyplus==15
- case key
- when Input::LEFT
- selection -= 1
- selection = 15 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>15
- when Input::UP
- if selection==15
- selection = 14
- else
- selection -= 5
- selection = 15 if selection<0
- end
- when Input::DOWN
- if selection==15
- selection = 0
- else
- selection += 5
- selection = 15 if selection>15
- end
- end
- elsif $Trainer.partyplus==14
- case key
- when Input::LEFT
- selection -= 1
- selection = 14 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>14
- when Input::UP
- if selection==14
- selection = 13
- else
- selection -= 7
- selection = 14 if selection<0
- end
- when Input::DOWN
- if selection==14
- selection = 0
- else
- selection += 7
- selection = 14 if selection>14
- end
- end
- elsif $Trainer.partyplus==12
- case key
- when Input::LEFT
- selection -= 1
- selection = 12 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>12
- when Input::UP
- if selection==12
- selection = 11
- else
- selection -= 3
- selection = 12 if selection<0
- end
- when Input::DOWN
- if selection==12
- selection = 0
- else
- selection += 3
- selection = 12 if selection>12
- end
- end
- elsif $Trainer.partyplus==10
- case key
- when Input::LEFT
- selection -= 1
- selection = 10 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>10
- when Input::UP
- if selection==10
- selection = 9
- else
- selection -= 2
- selection = 10 if selection<0
- end
- when Input::DOWN
- if selection==10
- selection = 0
- else
- selection += 2
- selection = 10 if selection>10
- end
- end
- elsif $Trainer.partyplus==9
- case key
- when Input::LEFT
- selection -= 1
- selection = 19 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>9
- when Input::UP
- if selection==9
- selection = 8
- else
- selection -= 3
- selection = 9 if selection<0
- end
- when Input::DOWN
- if selection==9
- selection = 0
- else
- selection += 3
- selection = 9 if selection>9
- end
- end
- elsif $Trainer.partyplus==8
- case key
- when Input::LEFT
- selection -= 1
- selection = 8 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>8
- when Input::UP
- if selection==8
- selection = 7
- else
- selection -= 2
- selection = 8 if selection<0
- end
- when Input::DOWN
- if selection==8
- selection = 0
- else
- selection += 2
- selection = 8 if selection>8
- end
- end
- elsif $Trainer.partyplus==5
- case key
- when Input::LEFT
- selection -= 1
- selection = 5 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>5
- when Input::UP
- if selection==5
- selection = 4
- else
- selection -= 1
- selection = 5 if selection<0
- end
- when Input::DOWN
- if selection==5
- selection = 0
- else
- selection += 1
- selection = 5 if selection>5
- end
- end
- elsif $Trainer.partyplus==4
- case key
- when Input::LEFT
- selection -= 1
- selection = 4 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>4
- when Input::UP
- if selection==4
- selection = 3
- else
- selection -= 2
- selection = 4 if selection<0
- end
- when Input::DOWN
- if selection==4
- selection = 0
- else
- selection += 2
- selection = 4 if selection>4
- end
- end
- elsif $Trainer.partyplus==3
- case key
- when Input::LEFT
- selection -= 1
- selection = 3 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>3
- when Input::UP
- if selection==3
- selection = 2
- else
- selection -= 1
- selection = 3 if selection<0
- end
- when Input::DOWN
- if selection==3
- selection = 0
- else
- selection += 1
- selection = 3 if selection>3
- end
- end
- elsif $Trainer.partyplus==2
- case key
- when Input::LEFT
- selection -= 1
- selection = 2 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>2
- when Input::UP
- if selection==2
- selection = 1
- else
- selection -= 2
- selection = 2 if selection<0
- end
- when Input::DOWN
- if selection==2
- selection = 0
- else
- selection += 2
- selection = 2 if selection>2
- end
- end
- elsif $Trainer.partyplus==1
- case key
- when Input::LEFT
- selection -= 1
- selection = 1 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>1
- when Input::UP
- if selection==1
- selection = 0
- else
- selection -= 1
- selection = 1 if selection<0
- end
- when Input::DOWN
- if selection==1
- selection = 0
- else
- selection += 1
- selection = 1 if selection>1
- end
- end
- else
- case key
- when Input::LEFT
- selection -= 1
- selection = 6 if selection<0
- when Input::RIGHT
- selection += 1
- selection = 0 if selection>6
- when Input::UP
- if selection==6
- selection = 5
- else
- selection -= 2
- selection = 6 if selection<0
- end
- when Input::DOWN
- if selection==6
- selection = 0
- else
- selection += 2
- selection = 6 if selection>6
- end
- end
- end
- return selection
- end
- def pbSelectBoxInternal(party)
- selection = @selection
- pbSetArrow(@sprites["arrow"],selection)
- pbUpdateOverlay(selection)
- pbSetMosaic(selection)
- loop do
- Graphics.update
- Input.update
- key = -1
- key = Input::DOWN if Input.repeat?(Input::DOWN)
- key = Input::RIGHT if Input.repeat?(Input::RIGHT)
- key = Input::LEFT if Input.repeat?(Input::LEFT)
- key = Input::UP if Input.repeat?(Input::UP)
- if key>=0
- pbPlayCursorSE
- selection = pbChangeSelection(key,selection)
- pbSetArrow(@sprites["arrow"],selection)
- if selection==-4
- nextbox = (@storage.currentBox+@storage.maxBoxes-1)%@storage.maxBoxes
- pbSwitchBoxToLeft(nextbox)
- @storage.currentBox = nextbox
- elsif selection==-5
- nextbox = (@storage.currentBox+1)%@storage.maxBoxes
- pbSwitchBoxToRight(nextbox)
- @storage.currentBox = nextbox
- end
- selection = -1 if selection==-4 || selection==-5
- pbUpdateOverlay(selection)
- pbSetMosaic(selection)
- end
- self.update
- if Input.trigger?(Input::L)
- pbPlayCursorSE
- nextbox = (@storage.currentBox+@storage.maxBoxes-1)%@storage.maxBoxes
- pbSwitchBoxToLeft(nextbox)
- @storage.currentBox = nextbox
- pbUpdateOverlay(selection)
- pbSetMosaic(selection)
- elsif Input.trigger?(Input::R)
- pbPlayCursorSE
- nextbox = (@storage.currentBox+1)%@storage.maxBoxes
- pbSwitchBoxToRight(nextbox)
- @storage.currentBox = nextbox
- pbUpdateOverlay(selection)
- pbSetMosaic(selection)
- elsif Input.trigger?(Input::F5) # Jump to box name
- if selection!=-1
- pbPlayCursorSE
- selection = -1
- pbSetArrow(@sprites["arrow"],selection)
- pbUpdateOverlay(selection)
- pbSetMosaic(selection)
- end
- elsif Input.trigger?(Input::A) && @command==0 # Organize only
- pbPlayDecisionSE
- pbSetQuickSwap(!@quickswap)
- elsif Input.trigger?(Input::B)
- @selection = selection
- return nil
- elsif Input.trigger?(Input::C)
- @selection = selection
- if selection>=0
- return [@storage.currentBox,selection]
- elsif selection==-1 # Box name
- return [-4,-1]
- elsif selection==-2 # Party Pokémon
- return [-2,-1]
- elsif selection==-3 # Close Box
- return [-3,-1]
- end
- end
- end
- end
- def pbSelectBox(party)
- return pbSelectBoxInternal(party) if @command==1 # Withdraw
- ret = nil
- loop do
- if !@choseFromParty
- ret = pbSelectBoxInternal(party)
- end
- if @choseFromParty || (ret && ret[0]==-2) # Party Pokémon
- if !@choseFromParty
- pbShowPartyTab
- @selection = 0
- end
- ret = pbSelectPartyInternal(party,false)
- if ret<0
- pbHidePartyTab
- @selection = 0
- @choseFromParty = false
- else
- @choseFromParty = true
- return [-1,ret]
- end
- else
- @choseFromParty = false
- return ret
- end
- end
- end
- def pbSelectPartyInternal(party,depositing)
- selection = @selection
- pbPartySetArrow(@sprites["arrow"],selection)
- pbUpdateOverlay(selection,party)
- pbSetMosaic(selection)
- lastsel = 1
- loop do
- Graphics.update
- Input.update
- key = -1
- key = Input::DOWN if Input.repeat?(Input::DOWN)
- key = Input::RIGHT if Input.repeat?(Input::RIGHT)
- key = Input::LEFT if Input.repeat?(Input::LEFT)
- key = Input::UP if Input.repeat?(Input::UP)
- if key>=0
- pbPlayCursorSE
- newselection = pbPartyChangeSelection(key,selection)
- if newselection==-1
- return -1 if !depositing
- elsif newselection==-2
- selection = lastsel
- else
- selection = newselection
- end
- pbPartySetArrow(@sprites["arrow"],selection)
- lastsel = selection if selection>0
- pbUpdateOverlay(selection,party)
- pbSetMosaic(selection)
- end
- self.update
- if Input.trigger?(Input::A) && @command==0 # Organize only
- pbPlayDecisionSE
- pbSetQuickSwap(!@quickswap)
- elsif Input.trigger?(Input::B)
- @selection = selection
- return -1
- elsif Input.trigger?(Input::C)
- if $Trainer.partyplus>=1
- if selection>=0 && selection<$Trainer.partyplus
- @selection = selection
- return selection
- elsif selection==$Trainer.partyplus # Close Box
- @selection = selection
- return (depositing) ? -3 : -1
- end
- else
- if selection>=0 && selection<6
- @selection = selection
- return selection
- elsif selection==6 # Close Box
- @selection = selection
- return (depositing) ? -3 : -1
- end
- end
- end
- end
- end
- def pbSelectParty(party)
- return pbSelectPartyInternal(party,true)
- end
- def pbChangeBackground(wp)
- @sprites["box"].refreshSprites = false
- alpha = 0
- Graphics.update
- self.update
- 16.times do
- alpha += 16
- Graphics.update
- Input.update
- @sprites["box"].color = Color.new(248,248,248,alpha)
- self.update
- end
- @sprites["box"].refreshBox = true
- @storage[@storage.currentBox].background = wp
- 4.times do
- Graphics.update
- Input.update
- self.update
- end
- 16.times do
- alpha -= 16
- Graphics.update
- Input.update
- @sprites["box"].color = Color.new(248,248,248,alpha)
- self.update
- end
- @sprites["box"].refreshSprites = true
- end
- def pbSwitchBoxToRight(newbox)
- newbox = PokemonBoxSprite.new(@storage,newbox,@boxviewport)
- newbox.x = 520
- Graphics.frame_reset
- begin
- Graphics.update
- Input.update
- @sprites["box"].x -= 32
- newbox.x -= 32
- self.update
- end until newbox.x<=184
- diff = newbox.x-184
- newbox.x = 184; @sprites["box"].x -= diff
- @sprites["box"].dispose
- @sprites["box"] = newbox
- end
- def pbSwitchBoxToLeft(newbox)
- newbox = PokemonBoxSprite.new(@storage,newbox,@boxviewport)
- newbox.x = -152
- Graphics.frame_reset
- begin
- Graphics.update
- Input.update
- @sprites["box"].x += 32
- newbox.x += 32
- self.update
- end until newbox.x>=184
- diff = newbox.x-184
- newbox.x = 184; @sprites["box"].x -= diff
- @sprites["box"].dispose
- @sprites["box"] = newbox
- end
- def pbJumpToBox(newbox)
- if @storage.currentBox!=newbox
- if newbox>@storage.currentBox
- pbSwitchBoxToRight(newbox)
- else
- pbSwitchBoxToLeft(newbox)
- end
- @storage.currentBox = newbox
- end
- end
- def pbSetMosaic(selection)
- if !@screen.pbHeldPokemon
- if @boxForMosaic!=@storage.currentBox || @selectionForMosaic!=selection
- @sprites["pokemon"].mosaic = 10
- @boxForMosaic = @storage.currentBox
- @selectionForMosaic = selection
- end
- end
- end
- def pbSetQuickSwap(value)
- @quickswap = value
- @sprites["arrow"].quickswap = value
- end
- def pbShowPartyTab
- if $Trainer.partyplus==40
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-356
- @sprites["boxparty"].y = Graphics.height-356
- elsif $Trainer.partyplus==35
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-350
- @sprites["boxparty"].y = Graphics.height-350
- elsif $Trainer.partyplus==32
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-306
- @sprites["boxparty"].y = Graphics.height-306
- elsif $Trainer.partyplus==30
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-350
- @sprites["boxparty"].y = Graphics.height-350
- elsif $Trainer.partyplus==28
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-302
- @sprites["boxparty"].y = Graphics.height-302
- elsif $Trainer.partyplus==25
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-350
- @sprites["boxparty"].y = Graphics.height-350
- elsif $Trainer.partyplus==24
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-302
- @sprites["boxparty"].y = Graphics.height-302
- elsif $Trainer.partyplus==21
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-254
- @sprites["boxparty"].y = Graphics.height-254
- elsif $Trainer.partyplus==20
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-302
- @sprites["boxparty"].y = Graphics.height-302
- elsif $Trainer.partyplus==18
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-254
- @sprites["boxparty"].y = Graphics.height-254
- elsif $Trainer.partyplus==16
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-302
- @sprites["boxparty"].y = Graphics.height-302
- elsif $Trainer.partyplus==15
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-254
- @sprites["boxparty"].y = Graphics.height-254
- elsif $Trainer.partyplus==14
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-206
- @sprites["boxparty"].y = Graphics.height-206
- elsif $Trainer.partyplus==12
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-302
- @sprites["boxparty"].y = Graphics.height-302
- elsif $Trainer.partyplus==10
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-350
- @sprites["boxparty"].y = Graphics.height-350
- elsif $Trainer.partyplus==9
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-254
- @sprites["boxparty"].y = Graphics.height-254
- elsif $Trainer.partyplus==8
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-302
- @sprites["boxparty"].y = Graphics.height-302
- elsif $Trainer.partyplus==5
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-334
- @sprites["boxparty"].y = Graphics.height-334
- elsif $Trainer.partyplus==4
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-206
- @sprites["boxparty"].y = Graphics.height-206
- elsif $Trainer.partyplus==3
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-238
- @sprites["boxparty"].y = Graphics.height-238
- elsif $Trainer.partyplus==2
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-158
- @sprites["boxparty"].y = Graphics.height-158
- elsif $Trainer.partyplus==1
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-141
- @sprites["boxparty"].y = Graphics.height-141
- else
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y -= 24
- self.update
- end until @sprites["boxparty"].y<=Graphics.height-352
- @sprites["boxparty"].y = Graphics.height-352
- end
- end
- def pbHidePartyTab
- begin
- Graphics.update
- Input.update
- @sprites["boxparty"].y += 24
- self.update
- end until @sprites["boxparty"].y>=Graphics.height
- @sprites["boxparty"].y = Graphics.height
- end
- def pbHold(selected)
- if selected[0]==-1
- @sprites["boxparty"].grabPokemon(selected[1],@sprites["arrow"])
- else
- @sprites["box"].grabPokemon(selected[1],@sprites["arrow"])
- end
- while @sprites["arrow"].grabbing?
- Graphics.update
- Input.update
- self.update
- end
- end
- def pbSwap(selected,heldpoke)
- heldpokesprite = @sprites["arrow"].heldPokemon
- boxpokesprite = nil
- if selected[0]==-1
- boxpokesprite = @sprites["boxparty"].getPokemon(selected[1])
- else
- boxpokesprite = @sprites["box"].getPokemon(selected[1])
- end
- if selected[0]==-1
- @sprites["boxparty"].setPokemon(selected[1],heldpokesprite)
- else
- @sprites["box"].setPokemon(selected[1],heldpokesprite)
- end
- @sprites["arrow"].setSprite(boxpokesprite)
- @sprites["pokemon"].mosaic = 10
- @boxForMosaic = @storage.currentBox
- @selectionForMosaic = selected[1]
- end
- def pbPlace(selected,heldpoke)
- heldpokesprite = @sprites["arrow"].heldPokemon
- @sprites["arrow"].place
- while @sprites["arrow"].placing?
- Graphics.update
- Input.update
- self.update
- end
- if selected[0]==-1
- @sprites["boxparty"].setPokemon(selected[1],heldpokesprite)
- else
- @sprites["box"].setPokemon(selected[1],heldpokesprite)
- end
- @boxForMosaic = @storage.currentBox
- @selectionForMosaic = selected[1]
- end
- def pbWithdraw(selected,heldpoke,partyindex)
- pbHold(selected) if !heldpoke
- pbShowPartyTab
- pbPartySetArrow(@sprites["arrow"],partyindex)
- pbPlace([-1,partyindex],heldpoke)
- pbHidePartyTab
- end
- def pbStore(selected,heldpoke,destbox,firstfree)
- if heldpoke
- if destbox==@storage.currentBox
- heldpokesprite = @sprites["arrow"].heldPokemon
- @sprites["box"].setPokemon(firstfree,heldpokesprite)
- @sprites["arrow"].setSprite(nil)
- else
- @sprites["arrow"].deleteSprite
- end
- else
- sprite = @sprites["boxparty"].getPokemon(selected[1])
- if destbox==@storage.currentBox
- @sprites["box"].setPokemon(firstfree,sprite)
- @sprites["boxparty"].setPokemon(selected[1],nil)
- else
- @sprites["boxparty"].deletePokemon(selected[1])
- end
- end
- end
- def pbRelease(selected,heldpoke)
- box = selected[0]
- index = selected[1]
- if heldpoke
- sprite = @sprites["arrow"].heldPokemon
- elsif box==-1
- sprite = @sprites["boxparty"].getPokemon(index)
- else
- sprite = @sprites["box"].getPokemon(index)
- end
- if sprite
- sprite.release
- while sprite.releasing?
- Graphics.update
- sprite.update
- self.update
- end
- end
- end
- def pbChooseBox(msg)
- commands = []
- for i in 0...@storage.maxBoxes
- box = @storage[i]
- if box
- commands.push(_INTL("{1} ({2}/{3})",box.name,box.nitems,box.length))
- end
- end
- return pbShowCommands(msg,commands,@storage.currentBox)
- end
- def pbBoxName(helptext,minchars,maxchars)
- oldsprites = pbFadeOutAndHide(@sprites)
- ret = pbEnterBoxName(helptext,minchars,maxchars)
- if ret.length>0
- @storage[@storage.currentBox].name = ret
- end
- @sprites["box"].refreshBox = true
- pbRefresh
- pbFadeInAndShow(@sprites,oldsprites)
- end
- def pbChooseItem(bag)
- ret = 0
- pbFadeOutIn(99999){
- scene = PokemonBag_Scene.new
- screen = PokemonBagScreen.new(scene,bag)
- ret = screen.pbChooseItemScreen(Proc.new{|item| pbCanHoldItem?(item) })
- }
- return ret
- end
- def pbSummary(selected,heldpoke)
- oldsprites = pbFadeOutAndHide(@sprites)
- scene = PokemonSummary_Scene.new
- screen = PokemonSummaryScreen.new(scene)
- if heldpoke
- screen.pbStartScreen([heldpoke],0)
- elsif selected[0]==-1
- @selection = screen.pbStartScreen(@storage.party,selected[1])
- pbPartySetArrow(@sprites["arrow"],@selection)
- pbUpdateOverlay(@selection,@storage.party)
- else
- @selection = screen.pbStartScreen(@storage.boxes[selected[0]],selected[1])
- pbSetArrow(@sprites["arrow"],@selection)
- pbUpdateOverlay(@selection)
- end
- pbFadeInAndShow(@sprites,oldsprites)
- end
- def pbMarkingSetArrow(arrow,selection)
- if selection>=0
- xvalues = [162,191,220,162,191,220,184,184]
- yvalues = [24,24,24,49,49,49,77,109]
- arrow.angle = 0
- arrow.mirror = false
- arrow.ox = 0
- arrow.oy = 0
- arrow.x = xvalues[selection]*2
- arrow.y = yvalues[selection]*2
- end
- end
- def pbMarkingChangeSelection(key,selection)
- case key
- when Input::LEFT
- if selection<6
- selection -= 1
- selection += 3 if selection%3==2
- end
- when Input::RIGHT
- if selection<6
- selection += 1
- selection -= 3 if selection%3==0
- end
- when Input::UP
- if selection==7; selection = 6
- elsif selection==6; selection = 4
- elsif selection<3; selection = 7
- else; selection -= 3
- end
- when Input::DOWN
- if selection==7; selection = 1
- elsif selection==6; selection = 7
- elsif selection>=3; selection = 6
- else; selection += 3
- end
- end
- return selection
- end
- def pbMark(selected,heldpoke)
- ret = 0
- @sprites["markingbg"].visible = true
- @sprites["markingoverlay"].visible = true
- msg = _INTL("Mark your Pokémon.")
- msgwindow = Window_UnformattedTextPokemon.newWithSize("",180,0,Graphics.width-180,32)
- msgwindow.viewport = @viewport
- msgwindow.visible = true
- msgwindow.letterbyletter = false
- msgwindow.text = msg
- msgwindow.resizeHeightToFit(msg,Graphics.width-180)
- pbBottomRight(msgwindow)
- base = Color.new(248,248,248)
- shadow = Color.new(80,80,80)
- pokemon = heldpoke
- if heldpoke
- pokemon = heldpoke
- elsif selected[0]==-1
- pokemon = @storage.party[selected[1]]
- else
- pokemon = @storage.boxes[selected[0]][selected[1]]
- end
- markings = pokemon.markings
- index = 0
- redraw = true
- markrect = Rect.new(0,0,16,16)
- loop do
- # Redraw the markings and text
- if redraw
- @sprites["markingoverlay"].bitmap.clear
- for i in 0...6
- markrect.x = i*16
- markrect.y = (markings&(1<<i)!=0) ? 16 : 0
- @sprites["markingoverlay"].bitmap.blt(336+58*(i%3),106+50*(i/3),@markingbitmap.bitmap,markrect)
- end
- textpos = [
- [_INTL("OK"),402,210,2,base,shadow,1],
- [_INTL("Cancel"),402,274,2,base,shadow,1]
- ]
- pbDrawTextPositions(@sprites["markingoverlay"].bitmap,textpos)
- pbMarkingSetArrow(@sprites["arrow"],index)
- redraw = false
- end
- Graphics.update
- Input.update
- key = -1
- key = Input::DOWN if Input.repeat?(Input::DOWN)
- key = Input::RIGHT if Input.repeat?(Input::RIGHT)
- key = Input::LEFT if Input.repeat?(Input::LEFT)
- key = Input::UP if Input.repeat?(Input::UP)
- if key>=0
- oldindex = index
- index = pbMarkingChangeSelection(key,index)
- pbPlayCursorSE if index!=oldindex
- pbMarkingSetArrow(@sprites["arrow"],index)
- end
- self.update
- if Input.trigger?(Input::B)
- pbPlayCancelSE
- break
- elsif Input.trigger?(Input::C)
- pbPlayDecisionSE
- if index==6 # OK
- pokemon.markings = markings
- break
- elsif index==7 # Cancel
- break
- else
- mask = (1<<index)
- if (markings&mask)==0
- markings |= mask
- else
- markings &= ~mask
- end
- redraw = true
- end
- end
- end
- @sprites["markingbg"].visible = false
- @sprites["markingoverlay"].visible = false
- msgwindow.dispose
- end
- def pbRefresh
- @sprites["box"].refresh
- @sprites["boxparty"].refresh
- end
- def pbHardRefresh
- oldPartyY = @sprites["boxparty"].y
- @sprites["box"].dispose
- @sprites["box"] = PokemonBoxSprite.new(@storage,@storage.currentBox,@boxviewport)
- @sprites["boxparty"].dispose
- @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party,@boxsidesviewport)
- @sprites["boxparty"].y = oldPartyY
- end
- def drawMarkings(bitmap,x,y,width,height,markings)
- markrect = Rect.new(0,0,16,16)
- for i in 0...8
- markrect.x = i*16
- markrect.y = (markings&(1<<i)!=0) ? 16 : 0
- bitmap.blt(x+i*16,y,@markingbitmap.bitmap,markrect)
- end
- end
- def pbUpdateOverlay(selection,party=nil)
- overlay = @sprites["overlay"].bitmap
- overlay.clear
- buttonbase = Color.new(248,248,248)
- buttonshadow = Color.new(80,80,80)
- pbDrawTextPositions(overlay,[
- [_INTL("Party: {1}",(@storage.party.length rescue 0)),270,328,2,buttonbase,buttonshadow,1],
- [_INTL("Exit"),446,328,2,buttonbase,buttonshadow,1],
- ])
- pokemon = nil
- if @screen.pbHeldPokemon
- pokemon = @screen.pbHeldPokemon
- elsif selection>=0
- pokemon = (party) ? party[selection] : @storage[@storage.currentBox,selection]
- end
- if !pokemon
- @sprites["pokemon"].visible = false
- return
- end
- @sprites["pokemon"].visible = true
- base = Color.new(88,88,80)
- shadow = Color.new(168,184,184)
- nonbase = Color.new(208,208,208)
- nonshadow = Color.new(224,224,224)
- pokename = pokemon.name
- textstrings = [
- [pokename,10,8,false,base,shadow]
- ]
- if !pokemon.egg?
- imagepos = []
- if pokemon.isMale?
- textstrings.push([_INTL("♂"),148,8,false,Color.new(24,112,216),Color.new(136,168,208)])
- elsif pokemon.isFemale?
- textstrings.push([_INTL("♀"),148,8,false,Color.new(248,56,32),Color.new(224,152,144)])
- end
- imagepos.push(["Graphics/Pictures/Storage/overlay_lv",6,246,0,0,-1,-1])
- textstrings.push([pokemon.level.to_s,28,234,false,base,shadow])
- if pokemon.ability>0
- textstrings.push([PBAbilities.getName(pokemon.ability),86,306,2,base,shadow])
- else
- textstrings.push([_INTL("No ability"),86,306,2,nonbase,nonshadow])
- end
- if pokemon.item>0
- textstrings.push([PBItems.getName(pokemon.item),86,342,2,base,shadow])
- else
- textstrings.push([_INTL("No item"),86,342,2,nonbase,nonshadow])
- end
- if pokemon.isShiny?
- imagepos.push(["Graphics/Pictures/shiny",156,198,0,0,-1,-1])
- end
- typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
- type1rect = Rect.new(0,pokemon.type1*28,64,28)
- type2rect = Rect.new(0,pokemon.type2*28,64,28)
- if pokemon.type1==pokemon.type2
- overlay.blt(52,272,typebitmap.bitmap,type1rect)
- else
- overlay.blt(18,272,typebitmap.bitmap,type1rect)
- overlay.blt(88,272,typebitmap.bitmap,type2rect)
- end
- drawMarkings(overlay,70,240,128,20,pokemon.markings)
- pbDrawImagePositions(overlay,imagepos)
- end
- pbDrawTextPositions(overlay,textstrings)
- @sprites["pokemon"].setPokemonBitmap(pokemon)
- end
- def update
- pbUpdateSpriteHash(@sprites)
- end
- end
- ################################################################################
- # Pc #
- ################################################################################
- #===============================================================================
- # PC menus
- #===============================================================================
- def pbPCItemStorage
- loop do
- command=Kernel.pbShowCommandsWithHelp(nil,
- [_INTL("Withdraw Item"),
- _INTL("Deposit Item"),
- _INTL("Toss Item"),
- _INTL("Exit")],
- [_INTL("Take out items from the PC."),
- _INTL("Store items in the PC."),
- _INTL("Throw away items stored in the PC."),
- _INTL("Go back to the previous menu.")],-1
- )
- if command==0 # Withdraw Item
- if !$PokemonGlobal.pcItemStorage
- $PokemonGlobal.pcItemStorage=PCItemStorage.new
- end
- if $PokemonGlobal.pcItemStorage.empty?
- Kernel.pbMessage(_INTL("There are no items."))
- else
- pbFadeOutIn(99999){
- scene = WithdrawItemScene.new
- screen = PokemonBagScreen.new(scene,$PokemonBag)
- ret = screen.pbWithdrawItemScreen
- }
- end
- elsif command==1 # Deposit Item
- pbFadeOutIn(99999){
- scene = PokemonBag_Scene.new
- screen = PokemonBagScreen.new(scene,$PokemonBag)
- ret = screen.pbDepositItemScreen
- }
- elsif command==2 # Toss Item
- if !$PokemonGlobal.pcItemStorage
- $PokemonGlobal.pcItemStorage=PCItemStorage.new
- end
- if $PokemonGlobal.pcItemStorage.empty?
- Kernel.pbMessage(_INTL("There are no items."))
- else
- pbFadeOutIn(99999){
- scene = TossItemScene.new
- screen = PokemonBagScreen.new(scene,$PokemonBag)
- ret = screen.pbTossItemScreen
- }
- end
- else
- break
- end
- end
- end
- def pbPCMailbox
- if !$PokemonGlobal.mailbox || $PokemonGlobal.mailbox.length==0
- Kernel.pbMessage(_INTL("There's no Mail here."))
- else
- loop do
- commands=[]
- for mail in $PokemonGlobal.mailbox
- commands.push(mail.sender)
- end
- commands.push(_INTL("Cancel"))
- command=Kernel.pbShowCommands(nil,commands,-1)
- if command>=0 && command<$PokemonGlobal.mailbox.length
- mailIndex=command
- command=Kernel.pbMessage(_INTL("What do you want to do with {1}'s Mail?",
- $PokemonGlobal.mailbox[mailIndex].sender),[
- _INTL("Read"),
- _INTL("Move to Bag"),
- _INTL("Give"),
- _INTL("Cancel")
- ],-1)
- if command==0 # Read
- pbFadeOutIn(99999){
- pbDisplayMail($PokemonGlobal.mailbox[mailIndex])
- }
- elsif command==1 # Move to Bag
- if Kernel.pbConfirmMessage(_INTL("The message will be lost. Is that OK?"))
- if $PokemonBag.pbStoreItem($PokemonGlobal.mailbox[mailIndex].item)
- Kernel.pbMessage(_INTL("The Mail was returned to the Bag with its message erased."))
- $PokemonGlobal.mailbox.delete_at(mailIndex)
- else
- Kernel.pbMessage(_INTL("The Bag is full."))
- end
- end
- elsif command==2 # Give
- pbFadeOutIn(99999){
- sscene = PokemonParty_Scene.new
- sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
- sscreen.pbPokemonGiveMailScreen(mailIndex)
- }
- end
- else
- break
- end
- end
- end
- end
- def pbTrainerPCMenu
- loop do
- command=Kernel.pbMessage(_INTL("What do you want to do?"),[
- _INTL("Item Storage"),
- _INTL("Mailbox"),
- _INTL("Turn Off")
- ],-1)
- if command==0
- pbPCItemStorage
- elsif command==1
- pbPCMailbox
- else
- break
- end
- end
- end
- class TrainerPC
- def shouldShow?
- return true
- end
- def name
- return _INTL("{1}'s PC",$Trainer.name)
- end
- def access
- Kernel.pbMessage(_INTL("\\se[PC access]Accessed {1}'s PC.",$Trainer.name))
- pbTrainerPCMenu
- end
- end
- def Kernel.pbGetStorageCreator
- creator=pbStorageCreator
- creator=_INTL("Bill") if !creator || creator==""
- return creator
- end
- class StorageSystemPC
- def shouldShow?
- return true
- end
- def name
- if $PokemonGlobal.seenStorageCreator
- return _INTL("{1}'s PC",Kernel.pbGetStorageCreator)
- else
- return _INTL("Someone's PC")
- end
- end
- def access
- Kernel.pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened."))
- loop do
- command=Kernel.pbShowCommandsWithHelp(nil,
- [_INTL("Organize Boxes"),
- _INTL("Withdraw Pokémon"),
- _INTL("Deposit Pokémon"),
- _INTL("See ya!")],
- [_INTL("Organize the Pokémon in Boxes and in your party."),
- _INTL("Move Pokémon stored in Boxes to your party."),
- _INTL("Store Pokémon in your party in Boxes."),
- _INTL("Return to the previous menu.")],-1
- )
- if command>=0 && command<3
- if command==1 # Withdraw
- if $Trainer.partyplus>=1
- if $PokemonStorage.party.length>=$Trainer.partyplus
- Kernel.pbMessage(_INTL("Your party is full!"))
- next
- end
- else
- if $PokemonStorage.party.length>=6
- Kernel.pbMessage(_INTL("Your party is full!"))
- next
- end
- end
- elsif command==2 # Deposit
- count=0
- for p in $PokemonStorage.party
- count+=1 if p && !p.egg? && p.hp>0
- end
- if count<=1
- Kernel.pbMessage(_INTL("Can't deposit the last Pokémon!"))
- next
- end
- end
- pbFadeOutIn(99999){
- scene = PokemonStorageScene.new
- screen = PokemonStorageScreen.new(scene,$PokemonStorage)
- screen.pbStartScreen(command)
- }
- else
- break
- end
- end
- end
- end
- def pbTrainerPC
- Kernel.pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name))
- pbTrainerPCMenu
- pbSEPlay("PC close")
- end
- def pbPokeCenterPC
- Kernel.pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name))
- loop do
- commands=PokemonPCList.getCommandList
- command=Kernel.pbMessage(_INTL("Which PC should be accessed?"),commands,commands.length)
- break if !PokemonPCList.callCommand(command)
- end
- pbSEPlay("PC close")
- end
- module PokemonPCList
- @@pclist=[]
- def self.registerPC(pc)
- @@pclist.push(pc)
- end
- def self.getCommandList()
- commands=[]
- for pc in @@pclist
- if pc.shouldShow?
- commands.push(pc.name)
- end
- end
- commands.push(_INTL("Log Off"))
- return commands
- end
- def self.callCommand(cmd)
- if cmd<0 || cmd>=@@pclist.length
- return false
- end
- i=0
- for pc in @@pclist
- if pc.shouldShow?
- if i==cmd
- pc.access()
- return true
- end
- i+=1
- end
- end
- return false
- end
- end
- PokemonPCList.registerPC(StorageSystemPC.new)
- PokemonPCList.registerPC(TrainerPC.new)
- ################################################################################
- # OrgBattle #
- ################################################################################
- def pbBattleFactoryPokemon(rule,numwins,numswaps,rentals)
- table=nil
- btpokemon=pbGetBTPokemon(pbBattleChallenge.currentChallenge)
- ivtable=[
- 0,6,3,6,
- 7,13,6,9,
- 14,20,9,12,
- 21,27,12,15,
- 28,34,15,21,
- 35,41,21,31,
- 42,-1,31,31
- ]
- groups=[
- 1,14,6,0,
- 15,21,5,1,
- 22,28,4,2,
- 29,35,3,3,
- 36,42,2,4,
- 43,-1,1,5
- ]
- if rule.ruleset.suggestedLevel!=100
- table=[
- 0,6,110,199,
- 7,13,162,266,
- 14,20,267,371,
- 21,27,372,467,
- 28,34,468,563,
- 35,41,564,659,
- 42,48,660,755,
- 49,-1,372,849
- ]
- else # Open Level (Level 100)
- table=[
- 0,6,372,467,
- 7,13,468,563,
- 14,20,564,659,
- 21,27,660,755,
- 28,34,372,881,
- 35,41,372,881,
- 42,48,372,881,
- 49,-1,372,881
- ]
- end
- pokemonNumbers=[0,0]
- ivs=[0,0]
- ivgroups=[6,0]
- for i in 0...table.length/4
- if table[i*4]<=numwins
- if (table[i*4+1]<0 || table[i*4+1]>=numwins)
- pokemonNumbers=[
- table[i*4+2]*btpokemon.length/882,
- table[i*4+3]*btpokemon.length/882
- ]
- end
- end
- end
- for i in 0...ivtable.length/4
- if ivtable[i*4]<=numwins
- if (ivtable[i*4+1]<0 || ivtable[i*4+1]>=numwins)
- ivs=[ivtable[i*4+2],ivtable[i*4+3]]
- end
- end
- end
- for i in 0...groups.length/4
- if groups[i*4]<=numswaps
- if (groups[i*4+1]<0 || groups[i*4+1]>=numswaps)
- ivgroups=[groups[i*4+2],groups[i*4+3]]
- end
- end
- end
- party=[]
- begin
- party.clear
- if $Trainer.partyplus>=1
- while party.length<$Trainer.partyplus
- rnd=pokemonNumbers[0]+rand(pokemonNumbers[1]-pokemonNumbers[0]+1)
- rndpoke=btpokemon[rnd]
- indvalue=(party.length<ivgroups[0]) ? ivs[0] : ivs[1]
- party.push(rndpoke.createPokemon(rule.ruleset.suggestedLevel,indvalue,nil))
- end
- else
- while party.length<6
- rnd=pokemonNumbers[0]+rand(pokemonNumbers[1]-pokemonNumbers[0]+1)
- rndpoke=btpokemon[rnd]
- indvalue=(party.length<ivgroups[0]) ? ivs[0] : ivs[1]
- party.push(rndpoke.createPokemon(rule.ruleset.suggestedLevel,indvalue,nil))
- end
- end
- end until rule.ruleset.isValid?(party)
- return party
- end
- ################################################################################
- # PokemonUtilities #
- ################################################################################
- #===============================================================================
- # Nicknaming and storing Pokémon
- #===============================================================================
- def pbBoxesFull?
- if $Trainer.partyplus>=1
- return !$Trainer || ($Trainer.party.length==$Trainer.partyplus && $PokemonStorage.full?)
- else
- return !$Trainer || ($Trainer.party.length==6 && $PokemonStorage.full?)
- end
- end
- def pbStorePokemon(pokemon)
- if pbBoxesFull?
- Kernel.pbMessage(_INTL("There's no more room for Pokémon!\1"))
- Kernel.pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
- return
- end
- pokemon.pbRecordFirstMoves
- if $Trainer.partyplus>=1
- if $Trainer.party.length<$Trainer.partyplus
- $Trainer.party[$Trainer.party.length] = pokemon
- else
- oldcurbox = $PokemonStorage.currentBox
- storedbox = $PokemonStorage.pbStoreCaught(pokemon)
- curboxname = $PokemonStorage[oldcurbox].name
- boxname = $PokemonStorage[storedbox].name
- creator = nil
- creator = Kernel.pbGetStorageCreator if $PokemonGlobal.seenStorageCreator
- if storedbox!=oldcurbox
- if creator
- Kernel.pbMessage(_INTL("Box \"{1}\" on {2}'s PC was full.\1",curboxname,creator))
- else
- Kernel.pbMessage(_INTL("Box \"{1}\" on someone's PC was full.\1",curboxname))
- end
- Kernel.pbMessage(_INTL("{1} was transferred to box \"{2}.\"",pokemon.name,boxname))
- else
- if creator
- Kernel.pbMessage(_INTL("{1} was transferred to {2}'s PC.\1",pokemon.name,creator))
- else
- Kernel.pbMessage(_INTL("{1} was transferred to someone's PC.\1",pokemon.name))
- end
- Kernel.pbMessage(_INTL("It was stored in box \"{1}.\"",boxname))
- end
- end
- else
- if $Trainer.party.length<6
- $Trainer.party[$Trainer.party.length] = pokemon
- else
- oldcurbox = $PokemonStorage.currentBox
- storedbox = $PokemonStorage.pbStoreCaught(pokemon)
- curboxname = $PokemonStorage[oldcurbox].name
- boxname = $PokemonStorage[storedbox].name
- creator = nil
- creator = Kernel.pbGetStorageCreator if $PokemonGlobal.seenStorageCreator
- if storedbox!=oldcurbox
- if creator
- Kernel.pbMessage(_INTL("Box \"{1}\" on {2}'s PC was full.\1",curboxname,creator))
- else
- Kernel.pbMessage(_INTL("Box \"{1}\" on someone's PC was full.\1",curboxname))
- end
- Kernel.pbMessage(_INTL("{1} was transferred to box \"{2}.\"",pokemon.name,boxname))
- else
- if creator
- Kernel.pbMessage(_INTL("{1} was transferred to {2}'s PC.\1",pokemon.name,creator))
- else
- Kernel.pbMessage(_INTL("{1} was transferred to someone's PC.\1",pokemon.name))
- end
- Kernel.pbMessage(_INTL("It was stored in box \"{1}.\"",boxname))
- end
- end
- end
- end
- #===============================================================================
- # Giving Pokémon to the player (will send to storage if party is full)
- #===============================================================================
- def pbAddPokemonSilent(pokemon,level=nil,seeform=true)
- return false if !pokemon || pbBoxesFull? || !$Trainer
- if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
- pokemon = getID(PBSpecies,pokemon)
- end
- if pokemon.is_a?(Integer) && level.is_a?(Integer)
- pokemon = PokeBattle_Pokemon.new(pokemon,level,$Trainer)
- end
- $Trainer.seen[pokemon.species] = true
- $Trainer.owned[pokemon.species] = true
- pbSeenForm(pokemon) if seeform
- pokemon.pbRecordFirstMoves
- if $Trainer.partyplus>=1
- if $Trainer.party.length<$Trainer.partyplus
- $Trainer.party[$Trainer.party.length] = pokemon
- else
- $PokemonStorage.pbStoreCaught(pokemon)
- end
- else
- if $Trainer.party.length<6
- $Trainer.party[$Trainer.party.length] = pokemon
- else
- $PokemonStorage.pbStoreCaught(pokemon)
- end
- end
- return true
- end
- #===============================================================================
- # Giving Pokémon/eggs to the player (can only add to party)
- #===============================================================================
- def pbAddToParty(pokemon,level=nil,seeform=true)
- if $Trainer.partyplus>=1
- return false if !pokemon || !$Trainer || $Trainer.party.length>=$Trainer.partyplus
- else
- return false if !pokemon || !$Trainer || $Trainer.party.length>=6
- end
- if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
- pokemon = getID(PBSpecies,pokemon)
- end
- if pokemon.is_a?(Integer) && level.is_a?(Integer)
- pokemon = PokeBattle_Pokemon.new(pokemon,level,$Trainer)
- end
- speciesname = PBSpecies.getName(pokemon.species)
- Kernel.pbMessage(_INTL("\\me[Pkmn get]{1} obtained {2}!\1",$Trainer.name,speciesname))
- pbNicknameAndStore(pokemon)
- pbSeenForm(pokemon) if seeform
- return true
- end
- def pbAddToPartySilent(pokemon,level=nil,seeform=true)
- if $Trainer.partyplus>=1
- return false if !pokemon || !$Trainer || $Trainer.party.length>=$Trainer.partyplus
- else
- return false if !pokemon || !$Trainer || $Trainer.party.length>=6
- end
- if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
- pokemon = getID(PBSpecies,pokemon)
- end
- if pokemon.is_a?(Integer) && level.is_a?(Integer)
- pokemon = PokeBattle_Pokemon.new(pokemon,level,$Trainer)
- end
- $Trainer.seen[pokemon.species] = true
- $Trainer.owned[pokemon.species] = true
- pbSeenForm(pokemon) if seeform
- pokemon.pbRecordFirstMoves
- $Trainer.party[$Trainer.party.length] = pokemon
- return true
- end
- def pbAddForeignPokemon(pokemon,level=nil,ownerName=nil,nickname=nil,ownerGender=0,seeform=true)
- if $Trainer.partyplus>=1
- return false if !pokemon || !$Trainer || $Trainer.party.length>=$Trainer.partyplus
- else
- return false if !pokemon || !$Trainer || $Trainer.party.length>=6
- end
- if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
- pokemon = getID(PBSpecies,pokemon)
- end
- if pokemon.is_a?(Integer) && level.is_a?(Integer)
- pokemon = PokeBattle_Pokemon.new(pokemon,level,$Trainer)
- end
- # Set original trainer to a foreign one (if ID isn't already foreign)
- if pokemon.trainerID==$Trainer.id
- pokemon.trainerID = $Trainer.getForeignID
- pokemon.ot = ownerName if ownerName && ownerName!=""
- pokemon.otgender = ownerGender
- end
- # Set nickname
- pokemon.name = nickname[0,PokeBattle_Pokemon::NAMELIMIT] if nickname && nickname!=""
- # Recalculate stats
- pokemon.calcStats
- if ownerName
- Kernel.pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon from {2}.\1",$Trainer.name,ownerName))
- else
- Kernel.pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon.\1",$Trainer.name))
- end
- pbStorePokemon(pokemon)
- $Trainer.seen[pokemon.species] = true
- $Trainer.owned[pokemon.species] = true
- pbSeenForm(pokemon) if seeform
- return true
- end
- def pbGenerateEgg(pokemon,text="")
- if $Trainer.partyplus>=1
- return false if !pokemon || !$Trainer || $Trainer.party.length>=$Trainer.partyplus
- else
- return false if !pokemon || !$Trainer || $Trainer.party.length>=6
- end
- if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
- pokemon = getID(PBSpecies,pokemon)
- end
- if pokemon.is_a?(Integer)
- pokemon = PokeBattle_Pokemon.new(pokemon,EGGINITIALLEVEL,$Trainer)
- end
- # Get egg steps
- dexdata = pbOpenDexData
- pbDexDataOffset(dexdata,pokemon.fSpecies,21)
- eggsteps = dexdata.fgetw
- dexdata.close
- # Set egg's details
- pokemon.name = _INTL("Egg")
- pokemon.eggsteps = eggsteps
- pokemon.obtainText = text
- pokemon.calcStats
- # Add egg to party
- $Trainer.party[$Trainer.party.length] = pokemon
- return true
- end
- ################################################################################
- # Utilities #
- ################################################################################
- #===============================================================================
- # Other utilities
- #===============================================================================
- def pbMoveTutorAnnotations(move,movelist=nil)
- ret = []
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- ret[i] = nil
- next if i>=$Trainer.party.length
- found = false
- for j in 0...4
- if !$Trainer.party[i].egg? && $Trainer.party[i].moves[j].id==move
- ret[i] = _INTL("LEARNED")
- found = true
- end
- end
- next if found
- species = $Trainer.party[i].species
- if !$Trainer.party[i].egg? && movelist && movelist.any?{|j| j==species }
- # Checked data from movelist
- ret[i] = _INTL("ABLE")
- elsif !$Trainer.party[i].egg? && $Trainer.party[i].isCompatibleWithMove?(move)
- # Checked data from PBS/tm.txt
- ret[i] = _INTL("ABLE")
- else
- ret[i] = _INTL("NOT ABLE")
- end
- end
- else
- for i in 0...6
- ret[i] = nil
- next if i>=$Trainer.party.length
- found = false
- for j in 0...4
- if !$Trainer.party[i].egg? && $Trainer.party[i].moves[j].id==move
- ret[i] = _INTL("LEARNED")
- found = true
- end
- end
- next if found
- species = $Trainer.party[i].species
- if !$Trainer.party[i].egg? && movelist && movelist.any?{|j| j==species }
- # Checked data from movelist
- ret[i] = _INTL("ABLE")
- elsif !$Trainer.party[i].egg? && $Trainer.party[i].isCompatibleWithMove?(move)
- # Checked data from PBS/tm.txt
- ret[i] = _INTL("ABLE")
- else
- ret[i] = _INTL("NOT ABLE")
- end
- end
- end
- return ret
- end
- ################################################################################
- # Debug #
- ################################################################################
- def pbDebugDayCare
- commands = [_INTL("Withdraw Pokémon 1"),
- _INTL("Withdraw Pokémon 2"),
- _INTL("Deposit Pokémon"),
- _INTL("Generate egg"),
- _INTL("Collect egg")]
- viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- viewport.z = 99999
- sprites = {}
- addBackgroundPlane(sprites,"background","hatchbg",viewport)
- sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,viewport)
- pbSetSystemFont(sprites["overlay"].bitmap)
- sprites["cmdwindow"] = Window_CommandPokemonEx.new(commands)
- cmdwindow = sprites["cmdwindow"]
- cmdwindow.x = 0
- cmdwindow.y = Graphics.height-128
- cmdwindow.width = Graphics.width
- cmdwindow.height = 128
- cmdwindow.viewport = viewport
- cmdwindow.columns = 2
- base = Color.new(248,248,248)
- shadow = Color.new(104,104,104)
- refresh = true
- loop do
- if refresh
- if pbEggGenerated?
- commands[3] = _INTL("Discard egg")
- else
- commands[3] = _INTL("Generate egg")
- end
- cmdwindow.commands = commands
- sprites["overlay"].bitmap.clear
- textpos = []
- for i in 0...2
- textpos.push([_INTL("Pokémon {1}",i+1),Graphics.width/4+i*Graphics.width/2,8,2,base,shadow])
- end
- for i in 0...pbDayCareDeposited
- next if !$PokemonGlobal.daycare[i][0]
- y = 40
- pkmn = $PokemonGlobal.daycare[i][0]
- initlevel = $PokemonGlobal.daycare[i][1]
- leveldiff = pkmn.level-initlevel
- textpos.push([pkmn.name+" ("+PBSpecies.getName(pkmn.species)+")",8+i*Graphics.width/2,y,0,base,shadow])
- y += 32
- if pkmn.isMale?
- textpos.push([_INTL("Male ♂"),8+i*Graphics.width/2,y,0,Color.new(128,192,248),shadow])
- elsif pkmn.isFemale?
- textpos.push([_INTL("Female ♀"),8+i*Graphics.width/2,y,0,Color.new(248,96,96),shadow])
- else
- textpos.push([_INTL("Genderless"),8+i*Graphics.width/2,y,0,base,shadow])
- end
- y += 32
- if initlevel>=PBExperience::MAXLEVEL
- textpos.push(["Lv. #{initlevel} (max)",8+i*Graphics.width/2,y,0,base,shadow])
- elsif leveldiff>0
- textpos.push(["Lv. #{initlevel} -> #{pkmn.level} (+#{leveldiff})",
- 8+i*Graphics.width/2,y,0,base,shadow])
- else
- textpos.push(["Lv. #{initlevel} (no change)",8+i*Graphics.width/2,y,0,base,shadow])
- end
- y += 32
- if pkmn.level<PBExperience::MAXLEVEL
- endexp = PBExperience.pbGetStartExperience(pkmn.level+1,pkmn.growthrate)
- textpos.push(["To next Lv.: #{endexp-pkmn.exp}",8+i*Graphics.width/2,y,0,base,shadow])
- y += 32
- end
- textpos.push(["Cost: $#{$game_variables[costVariable]}",8+i*Graphics.width/2,y,0,base,shadow])
- end
- if pbEggGenerated?
- textpos.push(["Egg waiting for collection",Graphics.width/2,216,2,Color.new(248,248,0),shadow])
- elsif pbDayCareDeposited==2
- if pbDayCareGetCompat==0
- textpos.push(["Pokémon cannot breed",Graphics.width/2,216,2,Color.new(248,96,96),shadow])
- else
- textpos.push(["Pokémon can breed",Graphics.width/2,216,2,Color.new(64,248,64),shadow])
- end
- end
- pbDrawTextPositions(sprites["overlay"].bitmap,textpos)
- refresh = false
- end
- pbUpdateSpriteHash(sprites)
- Graphics.update
- Input.update
- if Input.trigger?(Input::B)
- break
- elsif Input.trigger?(Input::C)
- ret = cmdwindow.index
- if $Trainer.partyplus>=1
- case cmdwindow.index
- when 0 # Withdraw Pokémon 1
- if !$PokemonGlobal.daycare[0][0]
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=$Trainer.partyplus
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
- else
- pbPlayDecisionSE
- pbDayCareGetDeposited(0,3,4)
- pbDayCareWithdraw(0)
- refresh = true
- end
- when 1 # Withdraw Pokémon 2
- if !$PokemonGlobal.daycare[1][0]
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=$Trainer.partyplus
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
- else
- pbPlayDecisionSE
- pbDayCareGetDeposited(1,3,4)
- pbDayCareWithdraw(1)
- refresh = true
- end
- when 2 # Deposit Pokémon
- if pbDayCareDeposited==2
- pbPlayBuzzerSE
- elsif $Trainer.party.length==0
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is empty, can't deposit Pokémon."))
- else
- pbPlayDecisionSE
- pbChooseNonEggPokemon(1,3)
- if pbGet(1)>=0
- pbDayCareDeposit(pbGet(1))
- refresh = true
- end
- end
- when 3 # Generate/discard egg
- if pbEggGenerated?
- pbPlayDecisionSE
- $PokemonGlobal.daycareEgg = 0
- $PokemonGlobal.daycareEggSteps = 0
- refresh = true
- else
- if pbDayCareDeposited!=2 || pbDayCareGetCompat==0
- pbPlayBuzzerSE
- else
- pbPlayDecisionSE
- $PokemonGlobal.daycareEgg = 1
- refresh = true
- end
- end
- when 4 # Collect egg
- if $PokemonGlobal.daycareEgg!=1
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=$Trainer.partyplus
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't collect the egg."))
- else
- pbPlayDecisionSE
- pbDayCareGenerateEgg
- $PokemonGlobal.daycareEgg = 0
- $PokemonGlobal.daycareEggSteps = 0
- Kernel.pbMessage(_INTL("Collected the {1} egg.",
- PBSpecies.getName($Trainer.lastParty.species)))
- refresh = true
- end
- end
- else
- case cmdwindow.index
- when 0 # Withdraw Pokémon 1
- if !$PokemonGlobal.daycare[0][0]
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=6
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
- else
- pbPlayDecisionSE
- pbDayCareGetDeposited(0,3,4)
- pbDayCareWithdraw(0)
- refresh = true
- end
- when 1 # Withdraw Pokémon 2
- if !$PokemonGlobal.daycare[1][0]
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=6
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
- else
- pbPlayDecisionSE
- pbDayCareGetDeposited(1,3,4)
- pbDayCareWithdraw(1)
- refresh = true
- end
- when 2 # Deposit Pokémon
- if pbDayCareDeposited==2
- pbPlayBuzzerSE
- elsif $Trainer.party.length==0
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is empty, can't deposit Pokémon."))
- else
- pbPlayDecisionSE
- pbChooseNonEggPokemon(1,3)
- if pbGet(1)>=0
- pbDayCareDeposit(pbGet(1))
- refresh = true
- end
- end
- when 3 # Generate/discard egg
- if pbEggGenerated?
- pbPlayDecisionSE
- $PokemonGlobal.daycareEgg = 0
- $PokemonGlobal.daycareEggSteps = 0
- refresh = true
- else
- if pbDayCareDeposited!=2 || pbDayCareGetCompat==0
- pbPlayBuzzerSE
- else
- pbPlayDecisionSE
- $PokemonGlobal.daycareEgg = 1
- refresh = true
- end
- end
- when 4 # Collect egg
- if $PokemonGlobal.daycareEgg!=1
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=6
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't collect the egg."))
- else
- pbPlayDecisionSE
- pbDayCareGenerateEgg
- $PokemonGlobal.daycareEgg = 0
- $PokemonGlobal.daycareEggSteps = 0
- Kernel.pbMessage(_INTL("Collected the {1} egg.",
- PBSpecies.getName($Trainer.lastParty.species)))
- refresh = true
- end
- end
- end
- end
- end
- pbDisposeSpriteHash(sprites)
- viewport.dispose
- end
- #===============================================================================
- # Individual trainer editor
- #===============================================================================
- module TrainerBattleProperty
- def self.set(settingname,oldsetting)
- return oldsetting if !oldsetting
- properties = [
- [_INTL("Trainer Type"),TrainerTypeProperty,_INTL("Name of the trainer type for this Trainer.")],
- [_INTL("Trainer Name"),StringProperty,_INTL("Name of the Trainer.")],
- [_INTL("Battle ID"),LimitProperty.new(255),_INTL("ID used to distinguish Trainers with the same name and trainer type.")],
- [_INTL("Pokémon 1"),TrainerPokemonProperty,_INTL("1st Pokémon.")],
- [_INTL("Pokémon 2"),TrainerPokemonProperty,_INTL("2nd Pokémon.")],
- [_INTL("Pokémon 3"),TrainerPokemonProperty,_INTL("3rd Pokémon.")],
- [_INTL("Pokémon 4"),TrainerPokemonProperty,_INTL("4th Pokémon.")],
- [_INTL("Pokémon 5"),TrainerPokemonProperty,_INTL("5th Pokémon.")],
- [_INTL("Pokémon 6"),TrainerPokemonProperty,_INTL("6th Pokémon.")],
- [_INTL("Pokémon 7"),TrainerPokemonProperty,_INTL("7th Pokémon.")],
- [_INTL("Pokémon 8"),TrainerPokemonProperty,_INTL("8th Pokémon.")],
- [_INTL("Pokémon 9"),TrainerPokemonProperty,_INTL("9th Pokémon.")],
- [_INTL("Pokémon 10"),TrainerPokemonProperty,_INTL("10th Pokémon.")],
- [_INTL("Pokémon 11"),TrainerPokemonProperty,_INTL("11th Pokémon.")],
- [_INTL("Pokémon 12"),TrainerPokemonProperty,_INTL("12th Pokémon.")],
- [_INTL("Pokémon 13"),TrainerPokemonProperty,_INTL("13th Pokémon.")],
- [_INTL("Pokémon 14"),TrainerPokemonProperty,_INTL("14th Pokémon.")],
- [_INTL("Pokémon 15"),TrainerPokemonProperty,_INTL("15th Pokémon.")],
- [_INTL("Pokémon 16"),TrainerPokemonProperty,_INTL("16th Pokémon.")],
- [_INTL("Pokémon 17"),TrainerPokemonProperty,_INTL("17th Pokémon.")],
- [_INTL("Pokémon 18"),TrainerPokemonProperty,_INTL("18th Pokémon.")],
- [_INTL("Pokémon 19"),TrainerPokemonProperty,_INTL("19th Pokémon.")],
- [_INTL("Pokémon 20"),TrainerPokemonProperty,_INTL("20th Pokémon.")],
- [_INTL("Pokémon 21"),TrainerPokemonProperty,_INTL("21th Pokémon.")],
- [_INTL("Pokémon 22"),TrainerPokemonProperty,_INTL("22th Pokémon.")],
- [_INTL("Pokémon 23"),TrainerPokemonProperty,_INTL("23th Pokémon.")],
- [_INTL("Pokémon 24"),TrainerPokemonProperty,_INTL("14th Pokémon.")],
- [_INTL("Pokémon 25"),TrainerPokemonProperty,_INTL("25th Pokémon.")],
- [_INTL("Pokémon 26"),TrainerPokemonProperty,_INTL("26th Pokémon.")],
- [_INTL("Pokémon 27"),TrainerPokemonProperty,_INTL("27th Pokémon.")],
- [_INTL("Pokémon 28"),TrainerPokemonProperty,_INTL("28th Pokémon.")],
- [_INTL("Pokémon 29"),TrainerPokemonProperty,_INTL("29th Pokémon.")],
- [_INTL("Pokémon 30"),TrainerPokemonProperty,_INTL("30th Pokémon.")],
- [_INTL("Pokémon 31"),TrainerPokemonProperty,_INTL("31th Pokémon.")],
- [_INTL("Pokémon 32"),TrainerPokemonProperty,_INTL("32th Pokémon.")],
- [_INTL("Pokémon 33"),TrainerPokemonProperty,_INTL("33th Pokémon.")],
- [_INTL("Pokémon 34"),TrainerPokemonProperty,_INTL("34th Pokémon.")],
- [_INTL("Pokémon 35"),TrainerPokemonProperty,_INTL("35th Pokémon.")],
- [_INTL("Pokémon 36"),TrainerPokemonProperty,_INTL("36th Pokémon.")],
- [_INTL("Pokémon 37"),TrainerPokemonProperty,_INTL("37th Pokémon.")],
- [_INTL("Pokémon 38"),TrainerPokemonProperty,_INTL("38th Pokémon.")],
- [_INTL("Pokémon 39"),TrainerPokemonProperty,_INTL("39th Pokémon.")],
- [_INTL("Pokémon 40"),TrainerPokemonProperty,_INTL("40th Pokémon.")],
- [_INTL("Item 1"),ItemProperty,_INTL("Item used by the trainer during battle.")],
- [_INTL("Item 2"),ItemProperty,_INTL("Item used by the trainer during battle.")],
- [_INTL("Item 3"),ItemProperty,_INTL("Item used by the trainer during battle.")],
- [_INTL("Item 4"),ItemProperty,_INTL("Item used by the trainer during battle.")],
- [_INTL("Item 5"),ItemProperty,_INTL("Item used by the trainer during battle.")],
- [_INTL("Item 6"),ItemProperty,_INTL("Item used by the trainer during battle.")],
- [_INTL("Item 7"),ItemProperty,_INTL("Item used by the trainer during battle.")],
- [_INTL("Item 8"),ItemProperty,_INTL("Item used by the trainer during battle.")]
- ]
- if !pbPropertyList(settingname,oldsetting,properties,true)
- oldsetting = nil
- else
- oldsetting = nil if !oldsetting[0] || oldsetting[0]==0
- end
- return oldsetting
- end
- def self.format(value)
- return value.inspect
- end
- end
- def pbTrainerBattleEditor
- selection = 0
- trainers = load_data("Data/trainers.dat")
- trainertypes = load_data("Data/trainertypes.dat")
- modified = false
- for trainer in trainers
- trtype = trainer[0]
- if !trainertypes || !trainertypes[trtype]
- trainer[0] = 0
- modified = true
- end
- end
- if modified
- save_data(trainers,"Data/trainers.dat")
- pbConvertTrainerData
- end
- pbListScreenBlock(_INTL("Trainer Battles"),TrainerBattleLister.new(selection,true)){|button,trtype|
- if trtype
- index = trtype[0]
- trainerdata = trtype[1]
- if button==Input::A
- if index>=0
- if Kernel.pbConfirmMessageSerious("Delete this trainer battle?")
- data = load_data("Data/trainers.dat")
- data.delete_at(index)
- save_data(data,"Data/trainers.dat")
- pbConvertTrainerData
- Kernel.pbMessage(_INTL("The Trainer battle was deleted."))
- end
- end
- elsif button==Input::C
- selection = index
- if selection<0
- ret=Kernel.pbMessage(_INTL("First, define the type of trainer."),[
- _INTL("Use existing type"),
- _INTL("Use new type"),
- _INTL("Cancel")],3)
- trainertype = -1
- trainername = ""
- if ret==0
- trainertype = pbListScreen(_INTL("TRAINER TYPE"),TrainerTypeLister.new(0,false))
- next if !trainertype
- trainertype = trainertype[0]
- next if trainertype<0
- elsif ret==1
- trainertype = pbTrainerTypeEditorNew(nil)
- next if trainertype<0
- else
- next
- end
- trainername = Kernel.pbMessageFreeText(_INTL("Now enter the trainer's name."),"",false,32)
- next if trainername==""
- trainerparty = pbGetFreeTrainerParty(trainertype,trainername)
- if trainerparty<0
- Kernel.pbMessage(_INTL("There is no room to create a trainer of that type and name."))
- next
- end
- ###############
- pbNewTrainer(trainertype,trainername,trainerparty)
- else
- data = [
- trainerdata[0], # Trainer type - 0
- trainerdata[1], # Trainer name - 1
- trainerdata[4], # ID - 2
- trainerdata[3][0], # Pokémon 1 - 3
- trainerdata[3][1], # Pokémon 2 - 4
- trainerdata[3][2], # Pokémon 3 - 5
- trainerdata[3][3], # Pokémon 4 - 6
- trainerdata[3][4], # Pokémon 5 - 7
- trainerdata[3][5], # Pokémon 6 - 8
- trainerdata[3][6], # Pokémon 7 - 9
- trainerdata[3][7], # Pokémon 8 - 10
- trainerdata[3][8], # Pokémon 9 - 11
- trainerdata[3][9], # Pokémon 10
- trainerdata[3][10], # Pokémon 11
- trainerdata[3][11], # Pokémon 12
- trainerdata[3][12], # Pokémon 13
- trainerdata[3][13], # Pokémon 14
- trainerdata[3][14], # Pokémon 15
- trainerdata[3][15], # Pokémon 16
- trainerdata[3][16], # Pokémon 17
- trainerdata[3][17], # Pokémon 18
- trainerdata[3][18], # Pokémon 19
- trainerdata[3][19], # Pokémon 20
- trainerdata[3][20], # Pokémon 21
- trainerdata[3][21], # Pokémon 22
- trainerdata[3][22], # Pokémon 23
- trainerdata[3][23], # Pokémon 24
- trainerdata[3][24], # Pokémon 25
- trainerdata[3][25], # Pokémon 26
- trainerdata[3][26], # Pokémon 27
- trainerdata[3][27], # Pokémon 28
- trainerdata[3][28], # Pokémon 29
- trainerdata[3][29], # Pokémon 30
- trainerdata[3][30], # Pokémon 31
- trainerdata[3][31], # Pokémon 32
- trainerdata[3][32], # Pokémon 33
- trainerdata[3][33], # Pokémon 34
- trainerdata[3][34], # Pokémon 35
- trainerdata[3][35], # Pokémon 36
- trainerdata[3][36], # Pokémon 37
- trainerdata[3][37], # Pokémon 38
- trainerdata[3][38], # Pokémon 39
- trainerdata[3][39], # Pokémon 40
- trainerdata[2][0], # Item 1
- trainerdata[2][1], # Item 2
- trainerdata[2][2], # Item 3
- trainerdata[2][3], # Item 4
- trainerdata[2][4], # Item 5
- trainerdata[2][5], # Item 6
- trainerdata[2][6], # Item 7
- trainerdata[2][7] # Item 8
- ]
- save = false
- while true
- data = TrainerBattleProperty.set(trainerdata[1],data)
- if data
- trainerdata = [
- data[0],
- data[1],
- [data[43],data[44],data[45],data[46],data[47],data[48],data[49],data[50]].find_all {|i| i && i!=0 }, # Item list
- [data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],data[14],data[15],data[16],data[17],data[18],data[19],data[20],data[21],data[22],data[23],data[24],data[25],data[26],data[27],data[28],data[29],data[30],data[31],data[32],data[33],data[34],data[35],data[36],data[37],data[38],data[39],data[40],data[41],data[42]].find_all {|i| i && i[TPSPECIES]!=0 }, # Pokémon list
- data[2]
- ]
- if trainerdata[3].length==0
- Kernel.pbMessage(_INTL("Can't save. The Pokémon list is empty."))
- elsif !trainerdata[1] || trainerdata[1].length==0
- Kernel.pbMessage(_INTL("Can't save. No name was entered."))
- else
- save = true
- break
- end
- else
- break
- end
- end
- if save
- data = load_data("Data/trainers.dat")
- data[index] = trainerdata
- save_data(data,"Data/trainers.dat")
- pbConvertTrainerData
- end
- end
- end
- end
- }
- end
- ################################################################################
- # Storage Inprovements #
- ################################################################################
- class PokemonStorage
- attr_reader :boxes
- attr_accessor :currentBox
- attr_writer :unlockedWallpapers
- BASICWALLPAPERQTY = 16
- def initialize(maxBoxes=STORAGEBOXES,maxPokemon=30)
- @boxes = []
- for i in 0...maxBoxes
- @boxes[i] = PokemonBox.new(_INTL("Box {1}",i+1),maxPokemon)
- @boxes[i].background = i%BASICWALLPAPERQTY
- end
- @currentBox = 0
- @boxmode = -1
- @unlockedWallpapers = []
- for i in 0...allWallpapers.length
- @unlockedWallpapers[i] = false
- end
- end
- def allWallpapers
- return [
- # Basic wallpapers
- _INTL("Forest"),_INTL("City"),_INTL("Desert"),_INTL("Savanna"),
- _INTL("Crag"),_INTL("Volcano"),_INTL("Snow"),_INTL("Cave"),
- _INTL("Beach"),_INTL("Seafloor"),_INTL("River"),_INTL("Sky"),
- _INTL("Poké Center"),_INTL("Machine"),_INTL("Checks"),_INTL("Simple"),
- # Special wallpapers
- _INTL("Space"),_INTL("Backyard"),_INTL("Nostalgic 1"),_INTL("Torchic"),
- _INTL("Trio 1"),_INTL("PikaPika 1"),_INTL("Legend 1"),_INTL("Team Galactic 1"),
- _INTL("Distortion"),_INTL("Contest"),_INTL("Nostalgic 2"),_INTL("Croagunk"),
- _INTL("Trio 2"),_INTL("PikaPika 2"),_INTL("Legend 2"),_INTL("Team Galactic 2"),
- _INTL("Heart"),_INTL("Soul"),_INTL("Big Brother"),_INTL("Pokéathlon"),
- _INTL("Trio 3"),_INTL("Spiky Pika"),_INTL("Kimono Girl"),_INTL("Revival")
- ]
- end
- def unlockedWallpapers
- @unlockedWallpapers = [] if !@unlockedWallpapers
- return @unlockedWallpapers
- end
- def availableWallpapers
- ret = [[],[]] # Names, IDs
- papers = allWallpapers
- @unlockedWallpapers = [] if !@unlockedWallpapers
- for i in 0...papers.length
- next if !isAvailableWallpaper(i)
- ret[0].push(papers[i]); ret[1].push(i)
- end
- return ret
- end
- def isAvailableWallpaper(i)
- @unlockedWallpapers = [] if !@unlockedWallpapers
- return true if i<BASICWALLPAPERQTY
- return true if @unlockedWallpapers[i]
- return false
- end
- def party
- $Trainer.party
- end
- def party=(value)
- raise ArgumentError.new("Not supported")
- end
- def maxBoxes
- return @boxes.length
- end
- def maxPokemon(box)
- return 0 if box>=self.maxBoxes
- return (box<0) ? 6 : self[box].length
- end
- def full?
- for i in 0...self.maxBoxes
- return false if !@boxes[i].full?
- end
- return true
- end
- def pbFirstFreePos(box)
- if box==-1
- ret = self.party.nitems
- return (ret==6) ? -1 : ret
- else
- for i in 0...maxPokemon(box)
- return i if !self[box,i]
- end
- return -1
- end
- end
- def [](x,y=nil)
- if y==nil
- return (x==-1) ? self.party : @boxes[x]
- else
- for i in @boxes
- raise "Box is a Pokémon, not a box" if i.is_a?(PokeBattle_Pokemon)
- end
- return (x==-1) ? self.party[y] : @boxes[x][y]
- end
- end
- def []=(x,y,value)
- if x==-1
- self.party[y] = value
- else
- @boxes[x][y] = value
- end
- end
- def pbCopy(boxDst,indexDst,boxSrc,indexSrc)
- if indexDst<0 && boxDst<self.maxBoxes
- found = false
- for i in 0...maxPokemon(boxDst)
- if !self[boxDst,i]
- found = true
- indexDst = i
- break
- end
- end
- return false if !found
- end
- if boxDst==-1
- if $Trainer.partyplus>=1
- return false if self.party.nitems>=$Trainer.partyplus
- else
- return false if self.party.nitems>=6
- end
- self.party[self.party.length] = self[boxSrc,indexSrc]
- self.party.compact!
- else
- pkmn = self[boxSrc,indexSrc]
- if !pkmn
- raise "Trying to copy nil to storage"
- end
- pkmn.heal
- pkmn.formTime = nil if pkmn.respond_to?("formTime") && pkmn.formTime
- self[boxDst,indexDst] = pkmn
- end
- return true
- end
- def pbMove(boxDst,indexDst,boxSrc,indexSrc)
- return false if !pbCopy(boxDst,indexDst,boxSrc,indexSrc)
- pbDelete(boxSrc,indexSrc)
- return true
- end
- def pbMoveCaughtToParty(pkmn)
- if $Trainer.partyplus>=1
- return false if self.party.nitems>=$Trainer.partyplus
- else
- return false if self.party.nitems>=6
- end
- self.party[self.party.length] = pkmn
- end
- def pbMoveCaughtToBox(pkmn,box)
- for i in 0...maxPokemon(box)
- if self[box,i]==nil
- if box>=0
- pkmn.heal
- pkmn.formTime = nil if pkmn.respond_to?("formTime") && pkmn.formTime
- end
- self[box,i] = pkmn
- return true
- end
- end
- return false
- end
- def pbStoreCaught(pkmn)
- for i in 0...maxPokemon(@currentBox)
- if self[@currentBox,i]==nil
- self[@currentBox,i] = pkmn
- return @currentBox
- end
- end
- for j in 0...self.maxBoxes
- for i in 0...maxPokemon(j)
- if self[j,i]==nil
- self[j,i] = pkmn
- @currentBox = j
- return @currentBox
- end
- end
- end
- return -1
- end
- def pbDelete(box,index)
- if self[box,index]
- self[box,index] = nil
- self.party.compact! if box==-1
- end
- end
- def clear
- for i in 0...self.maxBoxes
- @boxes[i].clear
- end
- end
- end
- ################################################################################
- # Battles #
- ################################################################################
- #===============================================================================
- # Start a double wild battle
- #===============================================================================
- def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false)
- if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
- if $Trainer.pokemonCount>0
- Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
- end
- pbSet(variable,1)
- $PokemonGlobal.nextBattleBGM = nil
- $PokemonGlobal.nextBattleME = nil
- $PokemonGlobal.nextBattleBack = nil
- return true
- end
- if species1.is_a?(String) || species1.is_a?(Symbol)
- species1 = getID(PBSpecies,species1)
- end
- if species2.is_a?(String) || species2.is_a?(Symbol)
- species2 = getID(PBSpecies,species2)
- end
- currentlevels = []
- for i in $Trainer.party
- currentlevels.push(i.level)
- end
- genwildpoke = pbGenerateWildPokemon(species1,level1)
- genwildpoke2 = pbGenerateWildPokemon(species2,level2)
- Events.onStartBattle.trigger(nil,genwildpoke)
- scene = pbNewBattleScene
- if $PokemonGlobal.partner
- othertrainer = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
- othertrainer.id = $PokemonGlobal.partner[2]
- othertrainer.party = $PokemonGlobal.partner[3]
- combinedParty = []
- for i in 0...$Trainer.party.length
- combinedParty[i] = $Trainer.party[i]
- end
- for i in 0...othertrainer.party.length
- combinedParty[40+i] = othertrainer.party[i]
- end
- battle = PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],[$Trainer,othertrainer],nil)
- battle.fullparty1 = true
- else
- battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],$Trainer,nil)
- battle.fullparty1 = false
- end
- battle.internalbattle = true
- battle.doublebattle = battle.pbDoubleBattleAllowed?()
- battle.cantescape = !canescape
- pbPrepareBattle(battle)
- decision = 0
- pbBattleAnimation(pbGetWildBattleBGM(species1),2,[genwildpoke,genwildpoke2]) {
- pbSceneStandby {
- decision = battle.pbStartBattle(canlose)
- }
- pbAfterBattle(decision,canlose)
- }
- Input.update
- pbSet(variable,decision)
- return (decision!=2 && decision!=5)
- end
- #===============================================================================
- # Start a trainer battle against one trainer
- #===============================================================================
- def pbTrainerBattle(trainerid,trainername,endspeech,
- doublebattle=false,trainerparty=0,canlose=false,variable=nil)
- if $Trainer.pokemonCount==0
- Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
- return false
- end
- if !$PokemonTemp.waitingTrainer && pbMapInterpreterRunning? &&
- ($Trainer.ablePokemonCount>1 || $Trainer.ablePokemonCount>0 && $PokemonGlobal.partner)
- thisEvent = pbMapInterpreter.get_character(0)
- triggeredEvents = $game_player.pbTriggeredTrainerEvents([2],false)
- otherEvent = []
- for i in triggeredEvents
- if i.id!=thisEvent.id && !$game_self_switches[[$game_map.map_id,i.id,"A"]]
- otherEvent.push(i)
- end
- end
- if otherEvent.length==1
- trainer = pbLoadTrainer(trainerid,trainername,trainerparty)
- Events.onTrainerPartyLoad.trigger(nil,trainer)
- if !trainer
- pbMissingTrainer(trainerid,trainername,trainerparty)
- return false
- end
- if trainer[2].length<=40
- $PokemonTemp.waitingTrainer=[trainer,thisEvent.id,endspeech]
- return false
- end
- end
- end
- trainer = pbLoadTrainer(trainerid,trainername,trainerparty)
- Events.onTrainerPartyLoad.trigger(nil,trainer)
- if !trainer
- pbMissingTrainer(trainerid,trainername,trainerparty)
- return false
- end
- if $PokemonGlobal.partner && ($PokemonTemp.waitingTrainer || doublebattle)
- othertrainer = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
- othertrainer.id = $PokemonGlobal.partner[2]
- othertrainer.party = $PokemonGlobal.partner[3]
- playerparty = []
- for i in 0...$Trainer.party.length
- playerparty[i] = $Trainer.party[i]
- end
- for i in 0...othertrainer.party.length
- playerparty[40+i] = othertrainer.party[i]
- end
- playertrainer = [$Trainer,othertrainer]
- fullparty1 = true
- doublebattle = true
- else
- playerparty = $Trainer.party
- playertrainer = $Trainer
- fullparty1 = false
- end
- if $PokemonTemp.waitingTrainer
- combinedParty = []
- fullparty2 = false
- if $PokemonTemp.waitingTrainer[0][2].length>3 || trainer[2].length>3
- for i in 0...$PokemonTemp.waitingTrainer[0][2].length
- combinedParty[i] = $PokemonTemp.waitingTrainer[0][2][i]
- end
- for i in 0...trainer[2].length
- combinedParty[40+i] = trainer[2][i]
- end
- fullparty2 = true
- else
- for i in 0...$PokemonTemp.waitingTrainer[0][2].length
- combinedParty[i] = $PokemonTemp.waitingTrainer[0][2][i]
- end
- for i in 0...trainer[2].length
- combinedParty[20+i] = trainer[2][i]
- end
- end
- scene = pbNewBattleScene
- battle = PokeBattle_Battle.new(scene,playerparty,combinedParty,playertrainer,
- [$PokemonTemp.waitingTrainer[0][0],trainer[0]])
- battle.fullparty1 = fullparty1
- battle.fullparty2 = fullparty2
- battle.doublebattle = battle.pbDoubleBattleAllowed?
- battle.endspeech = $PokemonTemp.waitingTrainer[2]
- battle.endspeech2 = endspeech
- battle.items = [$PokemonTemp.waitingTrainer[0][1],trainer[1]]
- trainerbgm = pbGetTrainerBattleBGM([$PokemonTemp.waitingTrainer[0][0],trainer[0]])
- else
- scene = pbNewBattleScene
- battle = PokeBattle_Battle.new(scene,playerparty,trainer[2],playertrainer,trainer[0])
- battle.fullparty1 = fullparty1
- battle.doublebattle = (doublebattle) ? battle.pbDoubleBattleAllowed? : false
- battle.endspeech = endspeech
- battle.items = trainer[1]
- trainerbgm = pbGetTrainerBattleBGM(trainer[0])
- end
- if Input.press?(Input::CTRL) && $DEBUG
- Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
- Kernel.pbMessage(_INTL("AFTER LOSING..."))
- Kernel.pbMessage(battle.endspeech)
- Kernel.pbMessage(battle.endspeech2) if battle.endspeech2
- if $PokemonTemp.waitingTrainer
- pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1],"A",true)
- $PokemonTemp.waitingTrainer = nil
- end
- return true
- end
- Events.onStartBattle.trigger(nil,nil)
- battle.internalbattle = true
- pbPrepareBattle(battle)
- restorebgm = true
- decision = 0
- Audio.me_stop
- tr = [trainer]; tr.push($PokemonTemp.waitingTrainer[0]) if $PokemonTemp.waitingTrainer
- pbBattleAnimation(trainerbgm,(battle.doublebattle) ? 3 : 1,tr) {
- pbSceneStandby {
- decision = battle.pbStartBattle(canlose)
- }
- pbAfterBattle(decision,canlose)
- if decision==1
- if $PokemonTemp.waitingTrainer
- pbMapInterpreter.pbSetSelfSwitch($PokemonTemp.waitingTrainer[1],"A",true)
- end
- end
- }
- Input.update
- pbSet(variable,decision)
- $PokemonTemp.waitingTrainer = nil
- return (decision==1)
- end
- #===============================================================================
- # Start a trainer battle against two trainers
- #===============================================================================
- def pbDoubleTrainerBattle(trainerid1, trainername1, trainerparty1, endspeech1,
- trainerid2, trainername2, trainerparty2, endspeech2,
- canlose=false,variable=nil)
- trainer1 = pbLoadTrainer(trainerid1,trainername1,trainerparty1)
- Events.onTrainerPartyLoad.trigger(nil,trainer1)
- if !trainer1
- pbMissingTrainer(trainerid1,trainername1,trainerparty1)
- end
- trainer2 = pbLoadTrainer(trainerid2,trainername2,trainerparty2)
- Events.onTrainerPartyLoad.trigger(nil,trainer2)
- if !trainer2
- pbMissingTrainer(trainerid2,trainername2,trainerparty2)
- end
- if !trainer1 || !trainer2
- return false
- end
- if $PokemonGlobal.partner
- othertrainer = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
- othertrainer.id = $PokemonGlobal.partner[2]
- othertrainer.party = $PokemonGlobal.partner[3]
- playerparty = []
- for i in 0...$Trainer.party.length
- playerparty[i] = $Trainer.party[i]
- end
- for i in 0...othertrainer.party.length
- playerparty[40+i] = othertrainer.party[i]
- end
- playertrainer = [$Trainer,othertrainer]
- fullparty1 = true
- else
- playerparty = $Trainer.party
- playertrainer = $Trainer
- fullparty1 = false
- end
- combinedParty = []
- for i in 0...trainer1[2].length
- combinedParty[i] = trainer1[2][i]
- end
- for i in 0...trainer2[2].length
- combinedParty[40+i] = trainer2[2][i]
- end
- scene = pbNewBattleScene
- battle = PokeBattle_Battle.new(scene,playerparty,combinedParty,playertrainer,
- [trainer1[0],trainer2[0]])
- battle.fullparty1 = fullparty1
- battle.fullparty2 = true
- battle.doublebattle = battle.pbDoubleBattleAllowed?()
- battle.endspeech = endspeech1
- battle.endspeech2 = endspeech2
- battle.items = [trainer1[1],trainer2[1]]
- trainerbgm = pbGetTrainerBattleBGM([trainer1[0],trainer2[0]])
- if Input.press?(Input::CTRL) && $DEBUG
- Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
- Kernel.pbMessage(_INTL("AFTER LOSING..."))
- Kernel.pbMessage(battle.endspeech)
- Kernel.pbMessage(battle.endspeech2) if battle.endspeech2 && battle.endspeech2!=""
- return true
- end
- Events.onStartBattle.trigger(nil,nil)
- battle.internalbattle = true
- pbPrepareBattle(battle)
- restorebgm = true
- decision = 0
- pbBattleAnimation(trainerbgm,(battle.doublebattle) ? 3 : 1,[trainer1,trainer2]) {
- pbSceneStandby {
- decision = battle.pbStartBattle(canlose)
- }
- pbAfterBattle(decision,canlose)
- }
- Input.update
- pbSet(variable,decision)
- return (decision==1)
- end
- ################################################################################
- # Item Reworking #
- ################################################################################
- ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc{|item,pokemon,scene|
- if isConst?(pokemon.species,PBSpecies,:KYUREM)
- if pokemon.hp>0
- if pokemon.fused!=nil
- if $Trainer.partyplus>=1
- if $Trainer.party.length>=$Trainer.partyplus
- scene.pbDisplay(_INTL("You have no room to separate the Pokémon."))
- next false
- else
- $Trainer.party[$Trainer.party.length]=pokemon.fused
- pokemon.fused=nil
- pokemon.form=0
- scene.pbHardRefresh
- scene.pbDisplay(_INTL("{1} changed Forme!",pokemon.name))
- next true
- end
- else
- if $Trainer.party.length>=6
- scene.pbDisplay(_INTL("You have no room to separate the Pokémon."))
- next false
- else
- $Trainer.party[$Trainer.party.length]=pokemon.fused
- pokemon.fused=nil
- pokemon.form=0
- scene.pbHardRefresh
- scene.pbDisplay(_INTL("{1} changed Forme!",pokemon.name))
- next true
- end
- end
- else
- chosen=scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?"))
- if chosen>=0
- poke2=$Trainer.party[chosen]
- if (isConst?(poke2.species,PBSpecies,:RESHIRAM) ||
- isConst?(poke2.species,PBSpecies,:ZEKROM)) && poke2.hp>0 && !poke2.egg?
- pokemon.form=1 if isConst?(poke2.species,PBSpecies,:RESHIRAM)
- pokemon.form=2 if isConst?(poke2.species,PBSpecies,:ZEKROM)
- pokemon.fused=poke2
- pbRemovePokemonAt(chosen)
- scene.pbHardRefresh
- scene.pbDisplay(_INTL("{1} changed Forme!",pokemon.name))
- next true
- elsif poke2.egg?
- scene.pbDisplay(_INTL("It cannot be fused with an Egg."))
- elsif poke2.hp<=0
- scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon."))
- elsif pokemon==poke2
- scene.pbDisplay(_INTL("It cannot be fused with itself."))
- else
- scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
- end
- else
- next false
- end
- end
- else
- scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
- end
- else
- scene.pbDisplay(_INTL("It had no effect."))
- next false
- end
- })
- ItemHandlers::BattleUseOnBattler.addIf(proc{|item|
- pbIsPokeBall?(item)},proc{|item,battler,scene| # Any Poké Ball
- battle=battler.battle
- if !battler.pbOpposing1.fainted? && !battler.pbOpposing2.fainted?
- if !pbIsSnagBall?(item)
- scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!"))
- return false
- end
- end
- if $Trainer.partyplus>=1
- if battle.pbPlayer.party.length>=$Trainer.partyplus && $PokemonStorage.full?
- scene.pbDisplay(_INTL("There is no room left in the PC!"))
- return false
- end
- else
- if battle.pbPlayer.party.length>=6 && $PokemonStorage.full?
- scene.pbDisplay(_INTL("There is no room left in the PC!"))
- return false
- end
- end
- return true
- })
- #===============================================================================
- # Battle scene (the visuals of the battle)
- #===============================================================================
- class PokeBattle_Scene
- attr_accessor :abortable
- attr_reader :viewport
- attr_reader :sprites
- BLANK = 0
- MESSAGEBOX = 1
- COMMANDBOX = 2
- FIGHTBOX = 3
- def initialize
- @battle=nil
- @lastcmd=[0,0,0,0]
- @lastmove=[0,0,0,0]
- @pkmnwindows=[nil,nil,nil,nil]
- @sprites={}
- @battlestart=true
- @messagemode=false
- @abortable=false
- @aborted=false
- end
- def pbUpdate
- partyAnimationUpdate
- @sprites["battlebg"].update if @sprites["battlebg"].respond_to?("update")
- end
- def pbGraphicsUpdate
- partyAnimationUpdate
- @sprites["battlebg"].update if @sprites["battlebg"].respond_to?("update")
- Graphics.update
- end
- def pbInputUpdate
- Input.update
- if Input.trigger?(Input::B) && @abortable && !@aborted
- @aborted=true
- @battle.pbAbort
- end
- end
- def pbShowWindow(windowtype)
- @sprites["messagebox"].visible = (windowtype==MESSAGEBOX ||
- windowtype==COMMANDBOX ||
- windowtype==FIGHTBOX ||
- windowtype==BLANK )
- @sprites["messagewindow"].visible = (windowtype==MESSAGEBOX)
- @sprites["commandwindow"].visible = (windowtype==COMMANDBOX)
- @sprites["fightwindow"].visible = (windowtype==FIGHTBOX)
- end
- def pbSetMessageMode(mode)
- @messagemode=mode
- msgwindow=@sprites["messagewindow"]
- if mode # Within Pokémon command
- msgwindow.baseColor=PokeBattle_SceneConstants::MENUBASECOLOR
- msgwindow.shadowColor=PokeBattle_SceneConstants::MENUSHADOWCOLOR
- msgwindow.opacity=255
- msgwindow.x=16
- msgwindow.width=Graphics.width
- msgwindow.height=96
- msgwindow.y=Graphics.height-msgwindow.height+2
- else
- msgwindow.baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
- msgwindow.shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
- msgwindow.opacity=0
- msgwindow.x=16
- msgwindow.width=Graphics.width-32
- msgwindow.height=96
- msgwindow.y=Graphics.height-msgwindow.height+2
- end
- end
- def pbWaitMessage
- if @briefmessage
- pbShowWindow(MESSAGEBOX)
- cw=@sprites["messagewindow"]
- 40.times do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- end
- cw.text=""
- cw.visible=false
- @briefmessage=false
- end
- end
- def pbDisplay(msg,brief=false)
- pbDisplayMessage(msg,brief)
- end
- def pbDisplayMessage(msg,brief=false)
- pbWaitMessage
- pbRefresh
- pbShowWindow(MESSAGEBOX)
- cw=@sprites["messagewindow"]
- cw.text=msg
- i=0
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- if i==40
- cw.text=""
- cw.visible=false
- return
- end
- if Input.trigger?(Input::C) || @abortable
- if cw.pausing?
- pbPlayDecisionSE() if !@abortable
- cw.resume
- end
- end
- if !cw.busy?
- if brief
- @briefmessage=true
- return
- end
- i+=1
- end
- end
- end
- def pbDisplayPausedMessage(msg)
- pbWaitMessage
- pbRefresh
- pbShowWindow(MESSAGEBOX)
- if @messagemode
- @switchscreen.pbDisplay(msg)
- return
- end
- cw=@sprites["messagewindow"]
- cw.text=_INTL("{1}\1",msg)
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- if Input.trigger?(Input::C) || @abortable
- if cw.busy?
- pbPlayDecisionSE() if cw.pausing? && !@abortable
- cw.resume
- elsif !inPartyAnimation?
- cw.text=""
- pbPlayDecisionSE()
- cw.visible=false if @messagemode
- return
- end
- end
- cw.update
- end
- end
- def pbDisplayConfirmMessage(msg)
- return pbShowCommands(msg,[_INTL("Yes"),_INTL("No")],1)==0
- end
- def pbShowCommands(msg,commands,defaultValue)
- pbWaitMessage
- pbRefresh
- pbShowWindow(MESSAGEBOX)
- dw=@sprites["messagewindow"]
- dw.text=msg
- cw = Window_CommandPokemon.new(commands)
- cw.x=Graphics.width-cw.width
- cw.y=Graphics.height-cw.height-dw.height
- cw.index=0
- cw.viewport=@viewport
- pbRefresh
- loop do
- cw.visible=!dw.busy?
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- dw.update
- if Input.trigger?(Input::B) && defaultValue>=0
- if dw.busy?
- pbPlayDecisionSE() if dw.pausing?
- dw.resume
- else
- cw.dispose
- dw.text=""
- return defaultValue
- end
- end
- if Input.trigger?(Input::C)
- if dw.busy?
- pbPlayDecisionSE() if dw.pausing?
- dw.resume
- else
- cw.dispose
- dw.text=""
- return cw.index
- end
- end
- end
- end
- def pbFrameUpdate(cw=nil)
- cw.update if cw
- for i in 0...4
- if @sprites["battlebox#{i}"]
- @sprites["battlebox#{i}"].update
- end
- if @sprites["pokemon#{i}"]
- @sprites["pokemon#{i}"].update
- end
- end
- end
- def pbRefresh
- for i in 0...4
- if @sprites["battlebox#{i}"]
- @sprites["battlebox#{i}"].refresh
- end
- end
- end
- def pbAddSprite(id,x,y,filename,viewport)
- sprite=IconSprite.new(x,y,viewport)
- if filename
- sprite.setBitmap(filename) rescue nil
- end
- @sprites[id]=sprite
- return sprite
- end
- def pbAddPlane(id,filename,viewport)
- sprite=AnimatedPlane.new(viewport)
- if filename
- sprite.setBitmap(filename)
- end
- @sprites[id]=sprite
- return sprite
- end
- def pbDisposeSprites
- pbDisposeSpriteHash(@sprites)
- end
- def pbBeginCommandPhase
- # Called whenever a new round begins.
- @battlestart=false
- end
- def pbShowOpponent(index)
- if @battle.opponent
- if @battle.opponent.is_a?(Array)
- trainerfile=pbTrainerSpriteFile(@battle.opponent[index].trainertype)
- else
- trainerfile=pbTrainerSpriteFile(@battle.opponent.trainertype)
- end
- else
- trainerfile="Graphics/Characters/trfront"
- end
- pbAddSprite("trainer",Graphics.width,PokeBattle_SceneConstants::FOETRAINER_Y,
- trainerfile,@viewport)
- if @sprites["trainer"].bitmap
- @sprites["trainer"].y-=@sprites["trainer"].bitmap.height
- @sprites["trainer"].z=8
- end
- 20.times do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- @sprites["trainer"].x-=6
- end
- end
- def pbHideOpponent
- 20.times do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- @sprites["trainer"].x+=6
- end
- end
- def pbShowHelp(text)
- @sprites["helpwindow"].resizeToFit(text,Graphics.width)
- @sprites["helpwindow"].y=0
- @sprites["helpwindow"].x=0
- @sprites["helpwindow"].text=text
- @sprites["helpwindow"].visible=true
- end
- def pbHideHelp
- @sprites["helpwindow"].visible=false
- 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
- 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::FOEBASEX,
- PokeBattle_SceneConstants::FOEBASEY,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
- # Returns whether the party line-ups are currently appearing on-screen
- def inPartyAnimation?
- return @enablePartyAnim && @partyAnimPhase<3
- end
- # Shows the party line-ups appearing on-screen
- def partyAnimationUpdate
- return if !inPartyAnimation?
- ballmovedist=16 # How far a ball moves each frame
- # Bar slides on
- if @partyAnimPhase==0
- @sprites["partybarfoe"].x+=16
- @sprites["partybarplayer"].x-=16
- if @sprites["partybarfoe"].x+@sprites["partybarfoe"].bitmap.width>=PokeBattle_SceneConstants::FOEPARTYBAR_X
- @sprites["partybarfoe"].x=PokeBattle_SceneConstants::FOEPARTYBAR_X-@sprites["partybarfoe"].bitmap.width
- @sprites["partybarplayer"].x=PokeBattle_SceneConstants::PLAYERPARTYBAR_X
- @partyAnimPhase=1
- end
- return
- end
- # Set up all balls ready to slide on
- if @partyAnimPhase==1
- @xposplayer=PokeBattle_SceneConstants::PLAYERPARTYBALL1_X
- counter=0
- # Make sure the ball starts off-screen
- while @xposplayer<Graphics.width
- counter+=1; @xposplayer+=ballmovedist
- end
- @xposenemy=PokeBattle_SceneConstants::FOEPARTYBALL1_X-counter*ballmovedist
- for i in 0...6
- # Choose the ball's graphic (player's side)
- ballgraphic="Graphics/Pictures/Battle/icon_ball_empty"
- if i<@battle.party1.length && @battle.party1[i]
- if @battle.party1[i].hp<=0 || @battle.party1[i].egg?
- ballgraphic="Graphics/Pictures/Battle/icon_ball_faint"
- elsif @battle.party1[i].status>0
- ballgraphic="Graphics/Pictures/Battle/icon_ball_status"
- else
- ballgraphic="Graphics/Pictures/Battle/icon_ball"
- end
- end
- pbAddSprite("player#{i}",
- @xposplayer+i*ballmovedist*6,PokeBattle_SceneConstants::PLAYERPARTYBALL1_Y,
- ballgraphic,@viewport)
- @sprites["player#{i}"].z=41
- # Choose the ball's graphic (opponent's side)
- ballgraphic="Graphics/Pictures/Battle/icon_ball_empty"
- enemyindex=i
- if @battle.doublebattle && i>=3
- enemyindex=(i%3)+@battle.pbSecondPartyBegin(1)
- end
- if enemyindex<@battle.party2.length && @battle.party2[enemyindex]
- if @battle.party2[enemyindex].hp<=0 || @battle.party2[enemyindex].egg?
- ballgraphic="Graphics/Pictures/Battle/icon_ball_faint"
- elsif @battle.party2[enemyindex].status>0
- ballgraphic="Graphics/Pictures/Battle/icon_ball_status"
- else
- ballgraphic="Graphics/Pictures/Battle/icon_ball"
- end
- end
- pbAddSprite("enemy#{i}",
- @xposenemy-i*ballmovedist*6,PokeBattle_SceneConstants::FOEPARTYBALL1_Y,
- ballgraphic,@viewport)
- @sprites["enemy#{i}"].z=41
- end
- @partyAnimPhase=2
- end
- # Balls slide on
- if @partyAnimPhase==2
- for i in 0...6
- if @sprites["enemy#{i}"].x<PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
- @sprites["enemy#{i}"].x+=ballmovedist
- @sprites["player#{i}"].x-=ballmovedist
- if @sprites["enemy#{i}"].x>=PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
- @sprites["enemy#{i}"].x=PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
- @sprites["player#{i}"].x=PokeBattle_SceneConstants::PLAYERPARTYBALL1_X+i*PokeBattle_SceneConstants::PLAYERPARTYBALL_GAP
- if i==5
- @partyAnimPhase=3
- end
- end
- end
- end
- end
- end
- def pbStartBattle(battle)
- # Called whenever the battle begins
- @battle=battle
- @lastcmd=[0,0,0,0]
- @lastmove=[0,0,0,0]
- @showingplayer=true
- @showingenemy=true
- @sprites.clear
- @viewport=Viewport.new(0,Graphics.height/2,Graphics.width,0)
- @viewport.z=99999
- @traineryoffset=(Graphics.height-320) # Adjust player's side for screen size
- @foeyoffset=(@traineryoffset*3/4).floor # Adjust foe's side for screen size
- pbBackdrop
- pbAddSprite("partybarfoe",
- PokeBattle_SceneConstants::FOEPARTYBAR_X,
- PokeBattle_SceneConstants::FOEPARTYBAR_Y,
- "Graphics/Pictures/Battle/overlay_lineup",@viewport)
- pbAddSprite("partybarplayer",
- PokeBattle_SceneConstants::PLAYERPARTYBAR_X,
- PokeBattle_SceneConstants::PLAYERPARTYBAR_Y,
- "Graphics/Pictures/Battle/overlay_lineup",@viewport)
- @sprites["partybarfoe"].x-=@sprites["partybarfoe"].bitmap.width
- @sprites["partybarplayer"].mirror=true
- @sprites["partybarfoe"].z=40
- @sprites["partybarplayer"].z=40
- @sprites["partybarfoe"].visible=false
- @sprites["partybarplayer"].visible=false
- if @battle.player.is_a?(Array)
- trainerfile=pbPlayerSpriteBackFile(@battle.player[0].trainertype)
- pbAddSprite("player",
- PokeBattle_SceneConstants::PLAYERTRAINERD1_X,
- PokeBattle_SceneConstants::PLAYERTRAINERD1_Y,trainerfile,@viewport)
- trainerfile=pbTrainerSpriteBackFile(@battle.player[1].trainertype)
- pbAddSprite("playerB",
- PokeBattle_SceneConstants::PLAYERTRAINERD2_X,
- PokeBattle_SceneConstants::PLAYERTRAINERD2_Y,trainerfile,@viewport)
- if @sprites["player"].bitmap
- if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
- @sprites["player"].src_rect.x=0
- @sprites["player"].src_rect.width=@sprites["player"].bitmap.width/5
- end
- @sprites["player"].x-=(@sprites["player"].src_rect.width/2)
- @sprites["player"].y-=@sprites["player"].bitmap.height
- @sprites["player"].z=30
- end
- if @sprites["playerB"].bitmap
- if @sprites["playerB"].bitmap.width>@sprites["playerB"].bitmap.height
- @sprites["playerB"].src_rect.x=0
- @sprites["playerB"].src_rect.width=@sprites["playerB"].bitmap.width/5
- end
- @sprites["playerB"].x-=(@sprites["playerB"].src_rect.width/2)
- @sprites["playerB"].y-=@sprites["playerB"].bitmap.height
- @sprites["playerB"].z=31
- end
- else
- trainerfile=pbPlayerSpriteBackFile(@battle.player.trainertype)
- pbAddSprite("player",
- PokeBattle_SceneConstants::PLAYERTRAINER_X,
- PokeBattle_SceneConstants::PLAYERTRAINER_Y,trainerfile,@viewport)
- if @sprites["player"].bitmap
- if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
- @sprites["player"].src_rect.x=0
- @sprites["player"].src_rect.width=@sprites["player"].bitmap.width/5
- end
- @sprites["player"].x-=(@sprites["player"].src_rect.width/2)
- @sprites["player"].y-=@sprites["player"].bitmap.height
- @sprites["player"].z=30
- end
- end
- if @battle.opponent
- if @battle.opponent.is_a?(Array)
- trainerfile=pbTrainerSpriteFile(@battle.opponent[1].trainertype)
- pbAddSprite("trainer2",
- PokeBattle_SceneConstants::FOETRAINERD2_X,
- PokeBattle_SceneConstants::FOETRAINERD2_Y,trainerfile,@viewport)
- trainerfile=pbTrainerSpriteFile(@battle.opponent[0].trainertype)
- pbAddSprite("trainer",
- PokeBattle_SceneConstants::FOETRAINERD1_X,
- PokeBattle_SceneConstants::FOETRAINERD1_Y,trainerfile,@viewport)
- else
- trainerfile=pbTrainerSpriteFile(@battle.opponent.trainertype)
- pbAddSprite("trainer",
- PokeBattle_SceneConstants::FOETRAINER_X,
- PokeBattle_SceneConstants::FOETRAINER_Y,trainerfile,@viewport)
- end
- else
- trainerfile="Graphics/Characters/trfront"
- pbAddSprite("trainer",
- PokeBattle_SceneConstants::FOETRAINER_X,
- PokeBattle_SceneConstants::FOETRAINER_Y,trainerfile,@viewport)
- end
- if @sprites["trainer"].bitmap
- @sprites["trainer"].x-=(@sprites["trainer"].bitmap.width/2)
- @sprites["trainer"].y-=@sprites["trainer"].bitmap.height
- @sprites["trainer"].z=8
- end
- if @sprites["trainer2"] && @sprites["trainer2"].bitmap
- @sprites["trainer2"].x-=(@sprites["trainer2"].bitmap.width/2)
- @sprites["trainer2"].y-=@sprites["trainer2"].bitmap.height
- @sprites["trainer2"].z=7
- end
- @sprites["shadow0"]=IconSprite.new(0,0,@viewport)
- @sprites["shadow0"].z=3
- pbAddSprite("shadow1",0,0,"Graphics/Pictures/Battle/object_shadow",@viewport)
- @sprites["shadow1"].z=3
- @sprites["shadow1"].visible=false
- @sprites["pokemon0"]=PokemonBattlerSprite.new(battle.doublebattle,0,@viewport)
- @sprites["pokemon0"].z=21
- @sprites["pokemon1"]=PokemonBattlerSprite.new(battle.doublebattle,1,@viewport)
- @sprites["pokemon1"].z=16
- if battle.doublebattle
- @sprites["shadow2"]=IconSprite.new(0,0,@viewport)
- @sprites["shadow2"].z=3
- pbAddSprite("shadow3",0,0,"Graphics/Pictures/Battle/object_shadow",@viewport)
- @sprites["shadow3"].z=3
- @sprites["shadow3"].visible=false
- @sprites["pokemon2"]=PokemonBattlerSprite.new(battle.doublebattle,2,@viewport)
- @sprites["pokemon2"].z=26
- @sprites["pokemon3"]=PokemonBattlerSprite.new(battle.doublebattle,3,@viewport)
- @sprites["pokemon3"].z=11
- end
- @sprites["battlebox0"]=PokemonDataBox.new(battle.battlers[0],battle.doublebattle,@viewport)
- @sprites["battlebox1"]=PokemonDataBox.new(battle.battlers[1],battle.doublebattle,@viewport)
- if battle.doublebattle
- @sprites["battlebox2"]=PokemonDataBox.new(battle.battlers[2],battle.doublebattle,@viewport)
- @sprites["battlebox3"]=PokemonDataBox.new(battle.battlers[3],battle.doublebattle,@viewport)
- end
- pbAddSprite("messagebox",0,Graphics.height-96,"Graphics/Pictures/Battle/overlay_message",@viewport)
- @sprites["messagebox"].z=90
- @sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
- @sprites["helpwindow"].visible=false
- @sprites["helpwindow"].z=90
- @sprites["messagewindow"]=Window_AdvancedTextPokemon.new("")
- @sprites["messagewindow"].letterbyletter=true
- @sprites["messagewindow"].viewport=@viewport
- @sprites["messagewindow"].z=100
- @sprites["commandwindow"]=CommandMenuDisplay.new(@viewport)
- @sprites["commandwindow"].z=100
- @sprites["fightwindow"]=FightMenuDisplay.new(nil,@viewport)
- @sprites["fightwindow"].z=100
- pbShowWindow(MESSAGEBOX)
- pbSetMessageMode(false)
- trainersprite1=@sprites["trainer"]
- trainersprite2=@sprites["trainer2"]
- if !@battle.opponent
- @sprites["trainer"].visible=false
- if @battle.party2.length>=1
- if @battle.party2.length==1
- species=@battle.party2[0].species
- @sprites["pokemon1"].setPokemonBitmap(@battle.party2[0],false)
- @sprites["pokemon1"].tone=Tone.new(-128,-128,-128,-128)
- @sprites["pokemon1"].x=PokeBattle_SceneConstants::FOEBATTLER_X
- @sprites["pokemon1"].x-=@sprites["pokemon1"].width/2
- @sprites["pokemon1"].y=PokeBattle_SceneConstants::FOEBATTLER_Y
- @sprites["pokemon1"].y+=adjustBattleSpriteY(@sprites["pokemon1"],species,1)
- @sprites["pokemon1"].visible=true
- @sprites["shadow1"].x=PokeBattle_SceneConstants::FOEBATTLER_X
- @sprites["shadow1"].y=PokeBattle_SceneConstants::FOEBATTLER_Y
- @sprites["shadow1"].x-=@sprites["shadow1"].bitmap.width/2 if @sprites["shadow1"].bitmap!=nil
- @sprites["shadow1"].y-=@sprites["shadow1"].bitmap.height/2 if @sprites["shadow1"].bitmap!=nil
- @sprites["shadow1"].visible=showShadow?(species)
- trainersprite1=@sprites["pokemon1"]
- elsif @battle.party2.length==2
- species=@battle.party2[0].species
- @sprites["pokemon1"].setPokemonBitmap(@battle.party2[0],false)
- @sprites["pokemon1"].tone=Tone.new(-128,-128,-128,-128)
- @sprites["pokemon1"].x=PokeBattle_SceneConstants::FOEBATTLERD1_X
- @sprites["pokemon1"].x-=@sprites["pokemon1"].width/2
- @sprites["pokemon1"].y=PokeBattle_SceneConstants::FOEBATTLERD1_Y
- @sprites["pokemon1"].y+=adjustBattleSpriteY(@sprites["pokemon1"],species,1)
- @sprites["pokemon1"].visible=true
- @sprites["shadow1"].x=PokeBattle_SceneConstants::FOEBATTLERD1_X
- @sprites["shadow1"].y=PokeBattle_SceneConstants::FOEBATTLERD1_Y
- @sprites["shadow1"].x-=@sprites["shadow1"].bitmap.width/2 if @sprites["shadow1"].bitmap!=nil
- @sprites["shadow1"].y-=@sprites["shadow1"].bitmap.height/2 if @sprites["shadow1"].bitmap!=nil
- @sprites["shadow1"].visible=showShadow?(species)
- trainersprite1=@sprites["pokemon1"]
- species=@battle.party2[1].species
- @sprites["pokemon3"].setPokemonBitmap(@battle.party2[1],false)
- @sprites["pokemon3"].tone=Tone.new(-128,-128,-128,-128)
- @sprites["pokemon3"].x=PokeBattle_SceneConstants::FOEBATTLERD2_X
- @sprites["pokemon3"].x-=@sprites["pokemon3"].width/2
- @sprites["pokemon3"].y=PokeBattle_SceneConstants::FOEBATTLERD2_Y
- @sprites["pokemon3"].y+=adjustBattleSpriteY(@sprites["pokemon3"],species,3)
- @sprites["pokemon3"].visible=true
- @sprites["shadow3"].x=PokeBattle_SceneConstants::FOEBATTLERD2_X
- @sprites["shadow3"].y=PokeBattle_SceneConstants::FOEBATTLERD2_Y
- @sprites["shadow3"].x-=@sprites["shadow3"].bitmap.width/2 if @sprites["shadow3"].bitmap!=nil
- @sprites["shadow3"].y-=@sprites["shadow3"].bitmap.height/2 if @sprites["shadow3"].bitmap!=nil
- @sprites["shadow3"].visible=showShadow?(species)
- trainersprite2=@sprites["pokemon3"]
- end
- end
- end
- #################
- # Move trainers/bases/etc. off-screen
- oldx=[]
- oldx[0]=@sprites["playerbase"].x; @sprites["playerbase"].x+=Graphics.width
- oldx[1]=@sprites["player"].x; @sprites["player"].x+=Graphics.width
- if @sprites["playerB"]
- oldx[2]=@sprites["playerB"].x; @sprites["playerB"].x+=Graphics.width
- end
- oldx[3]=@sprites["enemybase"].x; @sprites["enemybase"].x-=Graphics.width
- oldx[4]=trainersprite1.x; trainersprite1.x-=Graphics.width
- if trainersprite2
- oldx[5]=trainersprite2.x; trainersprite2.x-=Graphics.width
- end
- oldx[6]=@sprites["shadow1"].x; @sprites["shadow1"].x-=Graphics.width
- if @sprites["shadow3"]
- oldx[7]=@sprites["shadow3"].x; @sprites["shadow3"].x-=Graphics.width
- end
- @sprites["partybarfoe"].x-=PokeBattle_SceneConstants::FOEPARTYBAR_X
- @sprites["partybarplayer"].x+=Graphics.width-PokeBattle_SceneConstants::PLAYERPARTYBAR_X
- #################
- appearspeed=12
- (1+Graphics.width/appearspeed).times do
- tobreak=true
- if @viewport.rect.y>0
- @viewport.rect.y-=appearspeed/2
- @viewport.rect.y=0 if @viewport.rect.y<0
- @viewport.rect.height+=appearspeed
- @viewport.rect.height=Graphics.height if @viewport.rect.height>Graphics.height
- tobreak=false
- end
- if !tobreak
- for i in @sprites
- i[1].ox=@viewport.rect.x
- i[1].oy=@viewport.rect.y
- end
- end
- if @sprites["playerbase"].x>oldx[0]
- @sprites["playerbase"].x-=appearspeed; tobreak=false
- @sprites["playerbase"].x=oldx[0] if @sprites["playerbase"].x<oldx[0]
- end
- if @sprites["player"].x>oldx[1]
- @sprites["player"].x-=appearspeed; tobreak=false
- @sprites["player"].x=oldx[1] if @sprites["player"].x<oldx[1]
- end
- if @sprites["playerB"] && @sprites["playerB"].x>oldx[2]
- @sprites["playerB"].x-=appearspeed; tobreak=false
- @sprites["playerB"].x=oldx[2] if @sprites["playerB"].x<oldx[2]
- end
- if @sprites["enemybase"].x<oldx[3]
- @sprites["enemybase"].x+=appearspeed; tobreak=false
- @sprites["enemybase"].x=oldx[3] if @sprites["enemybase"].x>oldx[3]
- end
- if trainersprite1.x<oldx[4]
- trainersprite1.x+=appearspeed; tobreak=false
- trainersprite1.x=oldx[4] if trainersprite1.x>oldx[4]
- end
- if trainersprite2 && trainersprite2.x<oldx[5]
- trainersprite2.x+=appearspeed; tobreak=false
- trainersprite2.x=oldx[5] if trainersprite2.x>oldx[5]
- end
- if @sprites["shadow1"].x<oldx[6]
- @sprites["shadow1"].x+=appearspeed; tobreak=false
- @sprites["shadow1"].x=oldx[6] if @sprites["shadow1"].x>oldx[6]
- end
- if @sprites["shadow3"] && @sprites["shadow3"].x<oldx[7]
- @sprites["shadow3"].x+=appearspeed; tobreak=false
- @sprites["shadow3"].x=oldx[7] if @sprites["shadow3"].x>oldx[7]
- end
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if tobreak
- end
- #################
- if @battle.opponent
- @enablePartyAnim=true
- @partyAnimPhase=0
- @sprites["partybarfoe"].visible=true
- @sprites["partybarplayer"].visible=true
- else
- pbPlayCry(@battle.party2[0]) # Play cry for wild Pokémon
- @sprites["battlebox1"].appear
- @sprites["battlebox3"].appear if @battle.party2.length==2
- appearing=true
- begin
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- @sprites["pokemon1"].tone.red+=8 if @sprites["pokemon1"].tone.red<0
- @sprites["pokemon1"].tone.blue+=8 if @sprites["pokemon1"].tone.blue<0
- @sprites["pokemon1"].tone.green+=8 if @sprites["pokemon1"].tone.green<0
- @sprites["pokemon1"].tone.gray+=8 if @sprites["pokemon1"].tone.gray<0
- appearing=@sprites["battlebox1"].appearing
- if @battle.party2.length==2
- @sprites["pokemon3"].tone.red+=8 if @sprites["pokemon3"].tone.red<0
- @sprites["pokemon3"].tone.blue+=8 if @sprites["pokemon3"].tone.blue<0
- @sprites["pokemon3"].tone.green+=8 if @sprites["pokemon3"].tone.green<0
- @sprites["pokemon3"].tone.gray+=8 if @sprites["pokemon3"].tone.gray<0
- appearing=(appearing || @sprites["battlebox3"].appearing)
- end
- end while appearing
- # Show shiny animation for wild Pokémon
- if @battle.battlers[1].isShiny? && @battle.battlescene
- pbCommonAnimation("Shiny",@battle.battlers[1],nil)
- end
- if @battle.party2.length==2
- if @battle.battlers[3].isShiny? && @battle.battlescene
- pbCommonAnimation("Shiny",@battle.battlers[3],nil)
- end
- end
- end
- end
- def pbEndBattle(result)
- @abortable=false
- pbShowWindow(BLANK)
- # Fade out all sprites
- pbBGMFade(1.0)
- pbFadeOutAndHide(@sprites)
- pbDisposeSprites
- end
- def pbRecall(battlerindex)
- @briefmessage=false
- if @battle.pbIsOpposing?(battlerindex)
- origin=PokeBattle_SceneConstants::FOEBATTLER_Y
- if @battle.doublebattle
- origin=PokeBattle_SceneConstants::FOEBATTLERD1_Y if battlerindex==1
- origin=PokeBattle_SceneConstants::FOEBATTLERD2_Y if battlerindex==3
- end
- @sprites["shadow#{battlerindex}"].visible=false
- else
- origin=PokeBattle_SceneConstants::PLAYERBATTLER_Y
- if @battle.doublebattle
- origin=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if battlerindex==0
- origin=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if battlerindex==2
- end
- end
- spritePoke=@sprites["pokemon#{battlerindex}"]
- picturePoke=PictureEx.new(spritePoke.z)
- dims=[spritePoke.x,spritePoke.y]
- center=getSpriteCenter(spritePoke)
- # starting positions
- picturePoke.moveVisible(1,true)
- picturePoke.moveOrigin(1,PictureOrigin::Center)
- picturePoke.moveXY(0,1,center[0],center[1])
- # directives
- picturePoke.moveTone(10,1,Tone.new(248,248,248,248))
- delay=picturePoke.totalDuration
- picturePoke.moveSE(delay,"Audio/SE/Battle recall")
- picturePoke.moveZoom(15,delay,0)
- picturePoke.moveXY(15,delay,center[0],origin)
- picturePoke.moveVisible(picturePoke.totalDuration,false)
- picturePoke.moveTone(0,picturePoke.totalDuration,Tone.new(0,0,0,0))
- picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
- loop do
- picturePoke.update
- setPictureSprite(spritePoke,picturePoke)
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if !picturePoke.running?
- end
- 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["battlebox#{battlerindex}"].appear
- end
- if frame>=10
- sendout.update
- end
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
- !@sprites["battlebox#{battlerindex}"].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
- def pbSendOut(battlerindex,pkmn) # Player sending out Pokémon
- while inPartyAnimation?; end
- illusionpoke=@battle.battlers[battlerindex].effects[PBEffects::Illusion]
- balltype=pkmn.ballused
- balltype=illusionpoke.ballused if illusionpoke
- ballbitmap=sprintf("Graphics/Pictures/Battle/ball_%02d",balltype)
- pictureBall=PictureEx.new(32)
- delay=1
- pictureBall.moveVisible(delay,true)
- pictureBall.moveName(delay,ballbitmap)
- pictureBall.moveOrigin(delay,PictureOrigin::Center)
- # Setting the ball's movement path
- path=[[0, 146], [10, 134], [21, 122], [30, 112],
- [39, 104], [46, 99], [53, 95], [61, 93],
- [68, 93], [75, 96], [82, 102], [89, 111],
- [94, 121], [100, 134], [106, 150], [111, 166],
- [116, 183], [120, 199], [124, 216], [127, 238]]
- spriteBall=IconSprite.new(0,0,@viewport)
- spriteBall.visible=false
- angle=0
- multiplier=1.0
- if @battle.doublebattle
- multiplier=(battlerindex==0) ? 0.7 : 1.3
- end
- for coord in path
- # delay=pictureBall.totalDuration
- # pictureBall.moveAngle(0,delay,angle)
- # pictureBall.moveXY(1,delay,coord[0]*multiplier,coord[1])
- # angle+=40
- # angle%=360
- end
- pictureBall.adjustPosition(0,@traineryoffset)
- @sprites["battlebox#{battlerindex}"].visible=false
- @briefmessage=false
- fadeanim=nil
- if @showingplayer
- fadeanim=PlayerFadeAnimation.new(@sprites)
- end
- frame=0
- @sprites["pokemon#{battlerindex}"].setPokemonBitmap(pkmn,true)
- if illusionpoke
- @sprites["pokemon#{battlerindex}"].setPokemonBitmap(illusionpoke,true)
- end
- sendout=PokeballPlayerSendOutAnimation.new(@sprites["pokemon#{battlerindex}"],
- @sprites,@battle.battlers[battlerindex],illusionpoke,@battle.doublebattle)
- loop do
- fadeanim.update if fadeanim
- frame+=1
- if frame>1 && !pictureBall.running? && !@sprites["battlebox#{battlerindex}"].appearing
- @sprites["battlebox#{battlerindex}"].appear
- end
- if frame>=3 && !pictureBall.running?
- sendout.update
- end
- if (frame>=10 || !fadeanim) && pictureBall.running?
- pictureBall.update
- setPictureIconSprite(spriteBall,pictureBall)
- end
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
- !@sprites["battlebox#{battlerindex}"].appearing
- end
- spriteBall.dispose
- sendout.dispose
- if @battle.battlers[battlerindex].isShiny? && @battle.battlescene
- pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
- end
- if @showingplayer
- @showingplayer=false
- pbDisposeSprite(@sprites,"player")
- pbDisposeSprite(@sprites,"partybarplayer")
- for i in 0...6
- pbDisposeSprite(@sprites,"player#{i}")
- end
- end
- pbRefresh
- end
- def pbTrainerWithdraw(battle,pkmn)
- pbRefresh
- end
- def pbWithdraw(battle,pkmn)
- pbRefresh
- end
- def pbMoveString(move)
- ret=move.name
- typename=PBTypes.getName(move.type)
- if move.id>0
- ret+=_INTL(" ({1}) PP: {2}/{3}",typename,move.pp,move.totalpp)
- end
- return ret
- end
- def pbBeginAttackPhase
- pbSelectBattler(-1)
- pbGraphicsUpdate
- end
- def pbSafariStart
- @briefmessage=false
- @sprites["battlebox0"]=SafariDataBox.new(@battle,@viewport)
- @sprites["battlebox0"].appear
- loop do
- @sprites["battlebox0"].update
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if !@sprites["battlebox0"].appearing
- end
- pbRefresh
- end
- def pbResetCommandIndices
- @lastcmd=[0,0,0,0]
- end
- def pbResetMoveIndex(index)
- @lastmove[index]=0
- end
- def pbSafariCommandMenu(index)
- pbCommandMenuEx(index,[
- _INTL("What will\n{1} throw?",@battle.pbPlayer.name),
- _INTL("Ball"),
- _INTL("Bait"),
- _INTL("Rock"),
- _INTL("Run")
- ],2)
- end
- # Use this method to display the list of commands.
- # Return values: 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
- def pbCommandMenu(index)
- shadowTrainer=(hasConst?(PBTypes,:SHADOW) && @battle.opponent)
- ret=pbCommandMenuEx(index,[
- _INTL("What will\n{1} do?",@battle.battlers[index].name),
- _INTL("Fight"),
- _INTL("Bag"),
- _INTL("Pokémon"),
- shadowTrainer ? _INTL("Call") : _INTL("Run")
- ],(shadowTrainer ? 1 : 0))
- ret=4 if ret==3 && shadowTrainer # Convert "Run" to "Call"
- return ret
- end
- def pbCommandMenuEx(index,texts,mode=0) # Mode: 0 - regular battle
- pbShowWindow(COMMANDBOX) # 1 - Shadow Pokémon battle
- cw=@sprites["commandwindow"] # 2 - Safari Zone
- cw.setTexts(texts) # 3 - Bug Catching Contest
- cw.index=@lastcmd[index]
- cw.mode=mode
- pbSelectBattler(index)
- pbRefresh
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- # Update selected command
- if Input.trigger?(Input::LEFT) && (cw.index&1)==1
- pbPlayCursorSE
- cw.index-=1
- elsif Input.trigger?(Input::RIGHT) && (cw.index&1)==0
- pbPlayCursorSE
- cw.index+=1
- elsif Input.trigger?(Input::UP) && (cw.index&2)==2
- pbPlayCursorSE
- cw.index-=2
- elsif Input.trigger?(Input::DOWN) && (cw.index&2)==0
- pbPlayCursorSE
- cw.index+=2
- end
- if Input.trigger?(Input::C) # Confirm choice
- pbPlayDecisionSE
- ret=cw.index
- @lastcmd[index]=ret
- return ret
- elsif Input.trigger?(Input::B) && index==2 && @lastcmd[0]!=2 # Cancel
- pbPlayDecisionSE
- return -1
- end
- end
- end
- # Use this method to display the list of moves for a Pokémon
- def pbFightMenu(index)
- pbShowWindow(FIGHTBOX)
- cw = @sprites["fightwindow"]
- battler=@battle.battlers[index]
- cw.battler=battler
- lastIndex=@lastmove[index]
- if battler.moves[lastIndex].id!=0
- cw.setIndex(lastIndex)
- else
- cw.setIndex(0)
- end
- cw.megaButton=0
- cw.megaButton=1 if @battle.pbCanMegaEvolve?(index)
- pbSelectBattler(index)
- pbRefresh
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate(cw)
- # Update selected command
- if Input.trigger?(Input::LEFT) && (cw.index&1)==1
- pbPlayCursorSE if cw.setIndex(cw.index-1)
- elsif Input.trigger?(Input::RIGHT) && (cw.index&1)==0
- pbPlayCursorSE if cw.setIndex(cw.index+1)
- elsif Input.trigger?(Input::UP) && (cw.index&2)==2
- pbPlayCursorSE if cw.setIndex(cw.index-2)
- elsif Input.trigger?(Input::DOWN) && (cw.index&2)==0
- pbPlayCursorSE if cw.setIndex(cw.index+2)
- end
- if Input.trigger?(Input::C) # Confirm choice
- ret=cw.index
- pbPlayDecisionSE
- @lastmove[index]=ret
- 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
- return -1
- end
- end
- end
- # Use this method to display the inventory
- # The return value is the item chosen, or 0 if the choice was canceled.
- def pbItemMenu(index)
- ret=0
- retindex=-1
- pkmnid=-1
- endscene=true
- oldsprites=pbFadeOutAndHide(@sprites)
- oldlastpocket = $PokemonBag.lastpocket
- oldchoices = $PokemonBag.getAllChoices
- $PokemonBag.lastpocket = @baglastpocket if @baglastpocket!=nil
- $PokemonBag.setAllChoices(@bagchoices) if @bagchoices!=nil
- itemscene=PokemonBag_Scene.new
- itemscene.pbStartScene($PokemonBag,true,Proc.new{|item|
- $ItemData[item][ITEMBATTLEUSE]>0 || pbIsPokeBall?(item)
- },false)
- 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=[]
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- modparty.push(@battle.party1[@battle.party1order[i]])
- end
- else
- for i in 0...6
- modparty.push(@battle.party1[@battle.party1order[i]])
- end
- end
- pkmnlist=PokemonParty_Scene.new
- pkmnscreen=PokemonPartyScreen.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
- if ItemHandlers.hasBattleUseOnBattler(item)
- ret=item
- retindex=index
- break
- end
- end
- end
- end
- pbConsumeItemInBattle($PokemonBag,ret) if ret>0
- itemscene.pbEndScene if endscene
- @baglastpocket = $PokemonBag.lastpocket
- @bagchoices = $PokemonBag.getAllChoices
- $PokemonBag.lastpocket = oldlastpocket
- $PokemonBag.setAllChoices(oldchoices)
- pbFadeInAndShow(@sprites,oldsprites)
- return [ret,retindex]
- end
- # Called whenever a Pokémon should forget a move. It should return -1 if the
- # selection is canceled, or 0 to 3 to indicate the move to forget. The function
- # should not allow HM moves to be forgotten.
- def pbForgetMove(pokemon,moveToLearn)
- ret=-1
- pbFadeOutIn(99999){
- scene=PokemonSummary_Scene.new
- screen=PokemonSummaryScreen.new(scene)
- ret=screen.pbStartForgetScreen([pokemon],0,moveToLearn)
- }
- return ret
- end
- # Called whenever a Pokémon needs one of its moves chosen. Used for Ether.
- def pbChooseMove(pokemon,message)
- ret=-1
- pbFadeOutIn(99999){
- scene=PokemonSummary_Scene.new
- screen=PokemonSummaryScreen.new(scene)
- ret=screen.pbStartChooseMoveScreen([pokemon],0,message)
- }
- return ret
- end
- def pbNameEntry(helptext,pokemon)
- return pbEnterPokemonName(helptext,0,PokeBattle_Pokemon::NAMELIMIT,"",pokemon)
- end
- def pbSelectBattler(index,selectmode=1)
- numwindows=@battle.doublebattle ? 4 : 2
- for i in 0...numwindows
- sprite=@sprites["battlebox#{i}"]
- sprite.selected=(i==index) ? selectmode : 0
- sprite=@sprites["pokemon#{i}"]
- sprite.selected=(i==index) ? selectmode : 0
- end
- end
- def pbFirstTarget(index,targettype)
- case targettype
- when PBTargets::SingleNonUser
- for i in 0...4
- if i!=index && !@battle.battlers[i].fainted? &&
- @battle.battlers[index].pbIsOpposing?(i)
- return i
- end
- end
- when PBTargets::UserOrPartner
- return index
- end
- return -1
- end
- def pbUpdateSelected(index)
- numwindows=@battle.doublebattle ? 4 : 2
- for i in 0...numwindows
- if i==index
- @sprites["battlebox#{i}"].selected=2
- @sprites["pokemon#{i}"].selected=2
- else
- @sprites["battlebox#{i}"].selected=0
- @sprites["pokemon#{i}"].selected=0
- end
- end
- pbFrameUpdate
- end
- # Use this method to make the player choose a target
- # for certain moves in double battles.
- def pbChooseTarget(index,targettype)
- pbShowWindow(FIGHTBOX)
- cw = @sprites["fightwindow"]
- battler=@battle.battlers[index]
- cw.battler=battler
- lastIndex=@lastmove[index]
- if battler.moves[lastIndex].id!=0
- cw.setIndex(lastIndex)
- else
- cw.setIndex(0)
- end
- curwindow=pbFirstTarget(index,targettype)
- if curwindow==-1
- raise RuntimeError.new(_INTL("No targets somehow..."))
- end
- loop do
- pbGraphicsUpdate
- pbInputUpdate
- pbUpdateSelected(curwindow)
- if Input.trigger?(Input::B)
- pbUpdateSelected(-1)
- return -1
- elsif Input.trigger?(Input::C)
- pbUpdateSelected(-1)
- return curwindow
- end
- if curwindow>=0
- if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::DOWN)
- loop do
- case targettype
- when PBTargets::SingleNonUser
- case curwindow
- when 0; newcurwindow=2
- when 1; newcurwindow=0
- when 2; newcurwindow=3
- when 3; newcurwindow=1
- end
- when PBTargets::UserOrPartner
- newcurwindow=(curwindow+2)%4
- end
- curwindow=newcurwindow
- next if targettype==PBTargets::SingleNonUser && curwindow==index
- break if !@battle.battlers[curwindow].fainted?
- end
- elsif Input.trigger?(Input::LEFT) || Input.trigger?(Input::UP)
- loop do
- case targettype
- when PBTargets::SingleNonUser
- case curwindow
- when 0; newcurwindow=1
- when 1; newcurwindow=3
- when 2; newcurwindow=0
- when 3; newcurwindow=2
- end
- when PBTargets::UserOrPartner
- newcurwindow=(curwindow+2)%4
- end
- curwindow=newcurwindow
- next if targettype==PBTargets::SingleNonUser && curwindow==index
- break if !@battle.battlers[curwindow].fainted?
- end
- end
- end
- end
- end
- def pbSwitch(index,lax,cancancel)
- party=@battle.pbParty(index)
- partypos=@battle.party1order
- ret=-1
- # Fade out and hide all sprites
- visiblesprites=pbFadeOutAndHide(@sprites)
- pbShowWindow(BLANK)
- pbSetMessageMode(true)
- modparty=[]
- if $Trainer.partyplus>=1
- for i in 0...$Trainer.partyplus
- modparty.push(party[partypos[i]])
- end
- else
- for i in 0...6
- modparty.push(party[partypos[i]])
- end
- end
- scene=PokemonParty_Scene.new
- @switchscreen=PokemonPartyScreen.new(scene,modparty)
- @switchscreen.pbStartScene(_INTL("Choose a Pokémon."),
- @battle.doublebattle && !@battle.fullparty1)
- loop do
- scene.pbSetHelpText(_INTL("Choose a Pokémon."))
- activecmd=@switchscreen.pbChoosePokemon
- if cancancel && activecmd==-1
- ret=-1
- break
- end
- if activecmd>=0
- commands=[]
- cmdShift=-1
- cmdSummary=-1
- pkmnindex=partypos[activecmd]
- commands[cmdShift=commands.length]=_INTL("Switch In") if !party[pkmnindex].egg?
- commands[cmdSummary=commands.length]=_INTL("Summary")
- commands[commands.length]=_INTL("Cancel")
- command=scene.pbShowCommands(_INTL("Do what with {1}?",party[pkmnindex].name),commands)
- if cmdShift>=0 && command==cmdShift
- canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex,true) :
- @battle.pbCanSwitch?(index,pkmnindex,true)
- if canswitch
- ret=pkmnindex
- break
- end
- elsif cmdSummary>=0 && command==cmdSummary
- scene.pbSummary(activecmd)
- end
- end
- end
- @switchscreen.pbEndScene
- @switchscreen=nil
- pbShowWindow(BLANK)
- pbSetMessageMode(false)
- # back to main battle screen
- pbFadeInAndShow(@sprites,visiblesprites)
- return ret
- end
- def pbDamageAnimation(pkmn,effectiveness)
- pkmnsprite=@sprites["pokemon#{pkmn.index}"]
- shadowsprite=@sprites["shadow#{pkmn.index}"]
- sprite=@sprites["battlebox#{pkmn.index}"]
- oldshadowvisible=shadowsprite.visible
- oldvisible=sprite.visible
- sprite.selected=3
- @briefmessage=false
- 6.times do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- end
- case effectiveness
- when 0
- pbSEPlay("Battle damage normal")
- when 1
- pbSEPlay("Battle damage weak")
- when 2
- pbSEPlay("Battle damage super")
- end
- 8.times do
- pkmnsprite.visible=!pkmnsprite.visible
- if oldshadowvisible
- shadowsprite.visible=!shadowsprite.visible
- end
- 4.times do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- sprite.update
- end
- end
- sprite.selected=0
- sprite.visible=oldvisible
- end
- # This method is called whenever a Pokémon's HP changes.
- # Used to animate the HP bar.
- 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=@sprites["battlebox#{pkmn.index}"]
- 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("Pkmn 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
- 8.times do
- @sprites["battlebox#{pkmn.index}"].opacity-=32
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- end
- @sprites["battlebox#{pkmn.index}"].visible=false
- pkmn.pbResetForm
- end
- # Use this method to choose a command for the enemy.
- def pbChooseEnemyCommand(index)
- @battle.pbDefaultChooseEnemyCommand(index)
- end
- # Use this method to choose a new Pokémon for the enemy
- # The enemy's party is guaranteed to have at least one choosable member.
- def pbChooseNewEnemy(index,party)
- @battle.pbDefaultChooseNewEnemy(index,party)
- end
- # This method is called when the player wins a wild Pokémon battle.
- # This method can change the battle's music for example.
- def pbWildBattleSuccess
- pbBGMPlay(pbGetWildVictoryME())
- end
- # This method is called when the player wins a Trainer battle.
- # This method can change the battle's music for example.
- def pbTrainerBattleSuccess
- pbBGMPlay(pbGetTrainerVictoryME(@battle.opponent))
- end
- def pbEXPBar(pokemon,battler,startexp,endexp,tempexp1,tempexp2)
- if battler
- @sprites["battlebox#{battler.index}"].refreshExpLevel
- exprange=(endexp-startexp)
- startexplevel=0
- endexplevel=0
- if exprange!=0
- startexplevel=(tempexp1-startexp)*192/exprange
- endexplevel=(tempexp2-startexp)*192/exprange
- end
- @sprites["battlebox#{battler.index}"].animateEXP(startexplevel,endexplevel)
- while @sprites["battlebox#{battler.index}"].animatingEXP
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- @sprites["battlebox#{battler.index}"].update
- end
- end
- end
- def pbShowPokedex(species)
- pbFadeOutIn(99999){
- scene = PokemonPokedexInfo_Scene.new
- screen = PokemonPokedexInfoScreen.new(scene)
- screen.pbDexEntry(species)
- }
- end
- def pbChangeSpecies(attacker,species)
- pkmn=@sprites["pokemon#{attacker.index}"]
- shadow=@sprites["shadow#{attacker.index}"]
- back=!@battle.pbIsOpposing?(attacker.index)
- pkmn.setPokemonBitmapSpecies(attacker.pokemon,species,back)
- pkmn.x=-pkmn.bitmap.width/2
- pkmn.y=adjustBattleSpriteY(pkmn,species,attacker.index)
- if @battle.doublebattle
- case attacker.index
- when 0
- pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
- pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
- when 1
- pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
- pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
- when 2
- pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD2_X
- pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y
- when 3
- pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD2_X
- pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD2_Y
- end
- else
- pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLER_X if attacker.index==0
- pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y if attacker.index==0
- pkmn.x+=PokeBattle_SceneConstants::FOEBATTLER_X if attacker.index==1
- pkmn.y+=PokeBattle_SceneConstants::FOEBATTLER_Y if attacker.index==1
- end
- if shadow && !back
- shadow.visible=showShadow?(species)
- end
- end
- def pbChangePokemon(attacker,pokemon)
- pkmn=@sprites["pokemon#{attacker.index}"]
- shadow=@sprites["shadow#{attacker.index}"]
- back=!@battle.pbIsOpposing?(attacker.index)
- pkmn.setPokemonBitmap(pokemon,back)
- pkmn.x=-pkmn.bitmap.width/2
- pkmn.y=adjustBattleSpriteY(pkmn,pokemon.species,attacker.index)
- if @battle.doublebattle
- case attacker.index
- when 0
- pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
- pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
- when 1
- pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
- pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
- when 2
- pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD2_X
- pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y
- when 3
- pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD2_X
- pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD2_Y
- end
- else
- pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLER_X if attacker.index==0
- pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y if attacker.index==0
- pkmn.x+=PokeBattle_SceneConstants::FOEBATTLER_X if attacker.index==1
- pkmn.y+=PokeBattle_SceneConstants::FOEBATTLER_Y if attacker.index==1
- end
- if shadow && !back
- shadow.visible=showShadow?(pokemon.species)
- 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 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
- # Actual animation not found, get the default animation for the move's type
- move=PBMoveData.new(moveid)
- type=move.type
- typedefaultanim=[[:NORMAL,:TACKLE],
- [:FIGHTING,:COMETPUNCH],
- [:FLYING,:GUST],
- [:POISON,:SLUDGE],
- [:GROUND,:MUDSLAP],
- [:ROCK,:ROCKTHROW],
- [:BUG,:TWINEEDLE],
- [:GHOST,:NIGHTSHADE],
- [:STEEL,:GYROBALL],
- [:FIRE,:EMBER],
- [:WATER,:WATERGUN],
- [:GRASS,:RAZORLEAF],
- [:ELECTRIC,:THUNDERSHOCK],
- [:PSYCHIC,:CONFUSION],
- [:ICE,:ICEBALL],
- [:DRAGON,:DRAGONRAGE],
- [:DARK,:PURSUIT],
- [:FAIRY,:FAIRYWIND]]
- for i in typedefaultanim
- if isConst?(type,PBTypes,i[0]) && hasConst?(PBMoves,i[1])
- noflip=false
- if (userIndex&1)==0 # On player's side
- anim=move2anim[0][getConst(PBMoves,i[1])]
- else # On opposing side
- anim=move2anim[1][getConst(PBMoves,i[1])]
- noflip=true if anim
- anim=move2anim[0][getConst(PBMoves,i[1])] if !anim
- end
- return [anim,noflip] if anim
- break
- end
- end
- # Default animation for the move's type not found, use Tackle's animation
- if hasConst?(PBMoves,:TACKLE)
- anim=move2anim[0][getConst(PBMoves,:TACKLE)]
- return [anim,false] if anim
- end
- rescue
- return nil
- end
- return nil
- end
- def pbCommonAnimation(animname,user,target,hitnum=0)
- 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
- def pbAnimation(moveid,user,target,hitnum=0)
- animid=pbFindAnimation(moveid,user.index,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,true)
- else # On player's side, and/or using Move animation
- pbAnimationCore(animations[anim],user,target)
- end
- }
- if PBMoveData.new(moveid).function==0x69 && user && target # Transform
- # Change form to transformed version
- pbChangePokemon(user,target.pokemon)
- end
- end
- def pbAnimationCore(animation,user,target,oppmove=false)
- return if !animation
- @briefmessage=false
- usersprite=(user) ? @sprites["pokemon#{user.index}"] : nil
- targetsprite=(target) ? @sprites["pokemon#{target.index}"] : nil
- olduserx=usersprite ? usersprite.x : 0
- oldusery=usersprite ? usersprite.y : 0
- oldtargetx=targetsprite ? targetsprite.x : 0
- oldtargety=targetsprite ? targetsprite.y : 0
- if !targetsprite
- target=user if !target
- animplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
- userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
- userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.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),
- olduserx+(userwidth/2),oldusery+(userheight/2))
- else
- animplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
- 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))
- end
- animplayer.start
- while animplayer.playing?
- animplayer.update
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- 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
- def pbLevelUp(pokemon,battler,oldtotalhp,oldattack,olddefense,oldspeed,
- oldspatk,oldspdef)
- pbTopRightWindow(_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
- pokemon.totalhp-oldtotalhp,
- pokemon.attack-oldattack,
- pokemon.defense-olddefense,
- pokemon.spatk-oldspatk,
- pokemon.spdef-oldspdef,
- pokemon.speed-oldspeed))
- pbTopRightWindow(_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
- pokemon.totalhp,pokemon.attack,pokemon.defense,pokemon.spatk,pokemon.spdef,pokemon.speed))
- end
- def pbThrowAndDeflect(ball,targetBattler)
- @briefmessage=false
- balltype=pbGetBallType(ball)
- ball=sprintf("Graphics/Pictures/Battle/ball_%02d",balltype)
- # sprite
- spriteBall=IconSprite.new(0,0,@viewport)
- spriteBall.visible=false
- # picture
- pictureBall=PictureEx.new(@sprites["pokemon#{targetBattler}"].z+1)
- center=getSpriteCenter(@sprites["pokemon#{targetBattler}"])
- # starting positions
- pictureBall.moveVisible(1,true)
- pictureBall.moveName(1,ball)
- pictureBall.moveOrigin(1,PictureOrigin::Center)
- pictureBall.moveXY(0,1,10,180)
- # directives
- pictureBall.moveSE(1,"Audio/SE/Battle throw")
- pictureBall.moveCurve(30,1,150,70,30+Graphics.width/2,10,center[0],center[1])
- pictureBall.moveAngle(30,1,-1080)
- pictureBall.moveAngle(0,pictureBall.totalDuration,0)
- delay=pictureBall.totalDuration
- pictureBall.moveSE(delay,"Audio/SE/Battle ball drop")
- pictureBall.moveXY(20,delay,0,Graphics.height)
- loop do
- pictureBall.update
- setPictureIconSprite(spriteBall,pictureBall)
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if !pictureBall.running?
- end
- spriteBall.dispose
- end
- def pbThrow(ball,shakes,critical,targetBattler,showplayer=false)
- @briefmessage=false
- burst=-1
- animations=load_data("Data/PkmnAnimations.rxdata")
- for i in 0...2
- t=(i==0) ? ball : 0
- for j in 0...animations.length
- if animations[j]
- if animations[j].name=="Common:BallBurst#{t}"
- burst=t if burst<0
- break
- end
- end
- end
- break if burst>=0
- end
- pokeballThrow(ball,shakes,critical,targetBattler,self,@battle.battlers[targetBattler],burst,showplayer)
- end
- def pbThrowSuccess
- if !@battle.opponent
- @briefmessage=false
- pbMEPlay("Battle capture success")
- frames=(3.5*Graphics.frame_rate).to_i
- frames.times do
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- end
- end
- end
- def pbHideCaptureBall
- if @sprites["capture"]
- loop do
- break if @sprites["capture"].opacity<=0
- @sprites["capture"].opacity-=12
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- end
- end
- end
- def pbThrowBait
- @briefmessage=false
- ball=sprintf("Graphics/Pictures/Battle/object_bait")
- armanim=false
- if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
- armanim=true
- end
- # sprites
- spritePoke=@sprites["pokemon1"]
- spritePlayer=@sprites["player"]
- spriteBall=IconSprite.new(0,0,@viewport)
- spriteBall.visible=false
- # pictures
- pictureBall=PictureEx.new(spritePoke.z+1)
- picturePoke=PictureEx.new(spritePoke.z)
- picturePlayer=PictureEx.new(spritePoke.z+2)
- dims=[spritePoke.x,spritePoke.y]
- pokecenter=getSpriteCenter(@sprites["pokemon1"])
- playerpos=[@sprites["player"].x,@sprites["player"].y]
- ballendy=PokeBattle_SceneConstants::FOEBATTLER_Y-4
- # starting positions
- pictureBall.moveVisible(1,true)
- pictureBall.moveName(1,ball)
- pictureBall.moveOrigin(1,PictureOrigin::Center)
- pictureBall.moveXY(0,1,64,256)
- picturePoke.moveVisible(1,true)
- picturePoke.moveOrigin(1,PictureOrigin::Center)
- picturePoke.moveXY(0,1,pokecenter[0],pokecenter[1])
- picturePlayer.moveVisible(1,true)
- picturePlayer.moveName(1,@sprites["player"].name)
- picturePlayer.moveOrigin(1,PictureOrigin::TopLeft)
- picturePlayer.moveXY(0,1,playerpos[0],playerpos[1])
- # directives
- picturePoke.moveSE(1,"Audio/SE/Battle throw")
- pictureBall.moveCurve(30,1,64,256,Graphics.width/2,48,
- PokeBattle_SceneConstants::FOEBATTLER_X-48,
- PokeBattle_SceneConstants::FOEBATTLER_Y)
- pictureBall.moveAngle(30,1,-720)
- pictureBall.moveAngle(0,pictureBall.totalDuration,0)
- if armanim
- picturePlayer.moveSrc(1,@sprites["player"].bitmap.height,0)
- picturePlayer.moveXY(0,1,playerpos[0]-14,playerpos[1])
- picturePlayer.moveSrc(4,@sprites["player"].bitmap.height*2,0)
- picturePlayer.moveXY(0,4,playerpos[0]-12,playerpos[1])
- picturePlayer.moveSrc(8,@sprites["player"].bitmap.height*3,0)
- picturePlayer.moveXY(0,8,playerpos[0]+20,playerpos[1])
- picturePlayer.moveSrc(16,@sprites["player"].bitmap.height*4,0)
- picturePlayer.moveXY(0,16,playerpos[0]+16,playerpos[1])
- picturePlayer.moveSrc(40,0,0)
- picturePlayer.moveXY(0,40,playerpos[0],playerpos[1])
- end
- # Show Pokémon jumping before eating the bait
- picturePoke.moveSE(50,"Audio/SE/Player jump")
- picturePoke.moveXY(8,50,pokecenter[0],pokecenter[1]-8)
- picturePoke.moveXY(8,58,pokecenter[0],pokecenter[1])
- pictureBall.moveVisible(66,false)
- picturePoke.moveSE(66,"Audio/SE/Player jump")
- picturePoke.moveXY(8,66,pokecenter[0],pokecenter[1]-8)
- picturePoke.moveXY(8,74,pokecenter[0],pokecenter[1])
- # TODO: Show Pokémon eating the bait (pivots at the bottom right corner)
- picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
- picturePoke.moveXY(0,picturePoke.totalDuration,dims[0],dims[1])
- loop do
- pictureBall.update
- picturePoke.update
- picturePlayer.update
- setPictureIconSprite(spriteBall,pictureBall)
- setPictureSprite(spritePoke,picturePoke)
- setPictureIconSprite(spritePlayer,picturePlayer)
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if !pictureBall.running? && !picturePoke.running? && !picturePlayer.running?
- end
- spriteBall.dispose
- end
- def pbThrowRock
- @briefmessage=false
- ball=sprintf("Graphics/Pictures/Battle/object_rock")
- anger=sprintf("Graphics/Pictures/Battle/object_anger")
- armanim=false
- if @sprites["player"].bitmap.width>@sprites["player"].bitmap.height
- armanim=true
- end
- # sprites
- spritePoke=@sprites["pokemon1"]
- spritePlayer=@sprites["player"]
- spriteBall=IconSprite.new(0,0,@viewport)
- spriteBall.visible=false
- spriteAnger=IconSprite.new(0,0,@viewport)
- spriteAnger.visible=false
- # pictures
- pictureBall=PictureEx.new(spritePoke.z+1)
- picturePoke=PictureEx.new(spritePoke.z)
- picturePlayer=PictureEx.new(spritePoke.z+2)
- pictureAnger=PictureEx.new(spritePoke.z+1)
- dims=[spritePoke.x,spritePoke.y]
- pokecenter=getSpriteCenter(@sprites["pokemon1"])
- playerpos=[@sprites["player"].x,@sprites["player"].y]
- ballendy=PokeBattle_SceneConstants::FOEBATTLER_Y-4
- # starting positions
- pictureBall.moveVisible(1,true)
- pictureBall.moveName(1,ball)
- pictureBall.moveOrigin(1,PictureOrigin::Center)
- pictureBall.moveXY(0,1,64,256)
- picturePoke.moveVisible(1,true)
- picturePoke.moveOrigin(1,PictureOrigin::Center)
- picturePoke.moveXY(0,1,pokecenter[0],pokecenter[1])
- picturePlayer.moveVisible(1,true)
- picturePlayer.moveName(1,@sprites["player"].name)
- picturePlayer.moveOrigin(1,PictureOrigin::TopLeft)
- picturePlayer.moveXY(0,1,playerpos[0],playerpos[1])
- pictureAnger.moveVisible(1,false)
- pictureAnger.moveName(1,anger)
- pictureAnger.moveXY(0,1,pokecenter[0]-56,pokecenter[1]-48)
- pictureAnger.moveOrigin(1,PictureOrigin::Center)
- pictureAnger.moveZoom(0,1,100)
- # directives
- picturePoke.moveSE(1,"Audio/SE/Battle throw")
- pictureBall.moveCurve(30,1,64,256,Graphics.width/2,48,pokecenter[0],pokecenter[1])
- pictureBall.moveAngle(30,1,-720)
- pictureBall.moveAngle(0,pictureBall.totalDuration,0)
- pictureBall.moveSE(30,"Audio/SE/Battle damage weak")
- if armanim
- picturePlayer.moveSrc(1,@sprites["player"].bitmap.height,0)
- picturePlayer.moveXY(0,1,playerpos[0]-14,playerpos[1])
- picturePlayer.moveSrc(4,@sprites["player"].bitmap.height*2,0)
- picturePlayer.moveXY(0,4,playerpos[0]-12,playerpos[1])
- picturePlayer.moveSrc(8,@sprites["player"].bitmap.height*3,0)
- picturePlayer.moveXY(0,8,playerpos[0]+20,playerpos[1])
- picturePlayer.moveSrc(16,@sprites["player"].bitmap.height*4,0)
- picturePlayer.moveXY(0,16,playerpos[0]+16,playerpos[1])
- picturePlayer.moveSrc(40,0,0)
- picturePlayer.moveXY(0,40,playerpos[0],playerpos[1])
- end
- pictureBall.moveVisible(40,false)
- # Show Pokémon being angry
- pictureAnger.moveSE(48,"Audio/SE/Player jump")
- pictureAnger.moveVisible(48,true)
- pictureAnger.moveZoom(8,48,130)
- pictureAnger.moveZoom(8,56,100)
- pictureAnger.moveXY(0,64,pokecenter[0]+56,pokecenter[1]-64)
- pictureAnger.moveSE(64,"Audio/SE/Player jump")
- pictureAnger.moveZoom(8,64,130)
- pictureAnger.moveZoom(8,72,100)
- pictureAnger.moveVisible(80,false)
- picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
- picturePoke.moveXY(0,picturePoke.totalDuration,dims[0],dims[1])
- loop do
- pictureBall.update
- picturePoke.update
- picturePlayer.update
- pictureAnger.update
- setPictureIconSprite(spriteBall,pictureBall)
- setPictureSprite(spritePoke,picturePoke)
- setPictureIconSprite(spritePlayer,picturePlayer)
- setPictureIconSprite(spriteAnger,pictureAnger)
- pbGraphicsUpdate
- pbInputUpdate
- pbFrameUpdate
- break if !pictureBall.running? && !picturePoke.running? &&
- !picturePlayer.running? && !pictureAnger.running?
- end
- spriteBall.dispose
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement