Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================#
- # Party Plus #
- # by Pokeminer20 #
- #==============================================================================#
- # This script alters the normal properties of essentials to allow the player #
- # and the foes to use 8 pokemon as opposed to the normal 6 #
- # #
- # Not sure how this'll affect the mata of certain games but that's not my #
- # concern. Enjoy the script #
- #==============================================================================#
- # Aside from adding this above main, you will need to go to #
- # Class PokeBattle_Trainer and insert "attr_accessor(:partyplus)" anywhere #
- # between the start of the class and 'def trainerTypeName' as well as add #
- # "@partyplus=false" between 'def initialize(name,trainertype)' and #
- # 'for i in 1..PBSpecies.maxValue' #
- #==============================================================================#
- # To actually activate the script use "$Trainer.partyplus=true' in an event #
- # The 3 scenarios I personally see this being used in is as followed. #
- # 1: The script is turned on at the start of the game and is always active. #
- # 2: The script is Toggled depending on the story, On when outside of a Gym #
- # Challenge, 8 everywhere else #
- # 3: The script is used with the $Trainer.hardmode function included to create #
- # 4 seperate difficulty modes accessed after one playthrough. #
- #==============================================================================#
- # Diffuculty Modes:PP=Party Plus,HM=Hard Mode,!PP/!HM=Not Hardmode/Partyplus #
- # Easy Mode = PP/!MH: Foes use 6 mons, Player use 8 #
- # Normal Mode = !PP/!HM: All trainers use 6 Mons #
- # Hard = !PP/HM: PLayer use 6 mons, Foes use 8 #
- # Insane = PP/HM: All trainers use 8 Mons #
- #==============================================================================#
- # For modification past a limit of 8 locate most instances where #
- # $Trainer.party.limit correlates to 8 and increase it's value to whatever #
- # number you want. just be sure that values dictated under $Trainer.partyplus #
- # is also increased by the same value (Ex. if party is 12, add 4 to values) #
- #==============================================================================#
- #==============================================================================#
- # Please give credit when using this. #
- #==============================================================================#
- # Locate 'MAXPARTYSIZE = 6' and change it to 'MAXPARTYSIZE = 8'
- ################################################################################
- # Pokemon Storing #
- ################################################################################
- class PokeBattle_NullBattlePeer
- def pbOnEnteringBattle(battle,pokemon)
- end
- def pbStorePokemon(player,pokemon)
- if $Trainer.partyplus
- if player.party.length<8
- 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
- if player.party.length<8
- 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
- ################################################################################
- # Daycare Methods #
- ################################################################################
- def pbDayCareWithdraw(index)
- if $Trainer.partyplus
- if !$PokemonGlobal.daycare[index][0]
- raise _INTL("There's no Pokémon here...")
- elsif $Trainer.party.length>=8
- 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
- if $Trainer.party.length>=8
- 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
- ################################################################################
- # Item Reworking #
- ################################################################################
- ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc{|item,pokemon,scene|
- if $Trainer.partyplus
- if isConst?(pokemon.species,PBSpecies,:KYUREM)
- if pokemon.hp>0
- if pokemon.fused!=nil
- if $Trainer.party.length>=8
- 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
- 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
- else
- if isConst?(pokemon.species,PBSpecies,:KYUREM)
- if pokemon.hp>0
- if pokemon.fused!=nil
- 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
- 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
- end
- })
- ItemHandlers::BattleUseOnBattler.addIf(proc{|item|
- pbIsPokeBall?(item)},proc{|item,battler,scene| # Any Poké Ball
- battle=battler.battle
- if !battler.pbOpposing1.isFainted? && !battler.pbOpposing2.isFainted?
- 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
- if battle.pbPlayer.party.length>=8 && $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
- })
- ################################################################################
- # 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("ME Item 2")
- 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
- if createSpecies>0 && $Trainer.party.length<8
- 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)
- if $Trainer.partyplus
- super(viewport)
- self.x = [0,256,0,256,0,256,0,256][index]
- self.y = [-8,-8,72,72,152,152,232,232][index]
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/Pluspanel_blank")
- self.bitmap = @panelbgsprite.bitmap
- @text = nil
- else
- super(viewport)
- self.x = [0,256,0,256,0,256][index]
- self.y = [0,16,96,112,192,208][index]
- @panelbgsprite = AnimatedBitmap.new("Graphics/Pictures/Party/panel_blank")
- self.bitmap = @panelbgsprite.bitmap
- @text = nil
- end
- 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)
- if $Trainer.partyplus
- super(viewport)
- @pokemon = pokemon
- @active = (index==0) # true = rounded panel, false = rectangular panel
- @refreshing = true
- self.x = [0,256,0,256,0,256,0,256][index]
- self.y = [-8,-8,72,72,152,152,232,232][index]
- @panelbgsprite = ChangelingSprite.new(0,0,viewport)
- @panelbgsprite.z = self.z
- if @active # Rounded panel
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/Pluspanel_round")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/Pluspanel_round_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/Pluspanel_round_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/Pluspanel_round_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/Pluspanel_round_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/Pluspanel_round_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/Pluspanel_round_swap_sel2")
- else # Rectangular panel
- @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/Pluspanel_rect")
- @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/Pluspanel_rect_sel")
- @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/Pluspanel_rect_faint")
- @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/Pluspanel_rect_faint_sel")
- @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/Pluspanel_rect_swap")
- @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/Pluspanel_rect_swap_sel")
- @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/Pluspanel_rect_swap_sel2")
- end
- @hpbgsprite = ChangelingSprite.new(0,0,viewport)
- @hpbgsprite.z = self.z+1
- @hpbgsprite.addBitmap("able","Graphics/Pictures/Party/Plusoverlay_hp_back")
- @hpbgsprite.addBitmap("fainted","Graphics/Pictures/Party/Plusoverlay_hp_back_faint")
- @hpbgsprite.addBitmap("swap","Graphics/Pictures/Party/Plusoverlay_hp_back_swap")
- @ballsprite = ChangelingSprite.new(0,0,viewport)
- @ballsprite.z = self.z+1
- @ballsprite.addBitmap("desel","Graphics/Pictures/Party/Plusicon_ball")
- @ballsprite.addBitmap("sel","Graphics/Pictures/Party/Plusicon_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
- @hpbar = AnimatedBitmap.new("Graphics/Pictures/Party/Plusoverlay_hp")
- @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses"))
- @selected = false
- @preselected = false
- @switching = false
- @text = nil
- @refreshBitmap = true
- @refreshing = false
- refresh
- else
- super(viewport)
- @pokemon = pokemon
- @active = (index==0) # true = rounded panel, false = rectangular panel
- @refreshing = true
- self.x = [0,256,0,256,0,256][index]
- self.y = [0,16,96,112,192,208][index]
- @panelbgsprite = ChangelingSprite.new(0,0,viewport)
- @panelbgsprite.z = self.z
- 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
- @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")
- @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
- @hpbar = AnimatedBitmap.new("Graphics/Pictures/Party/overlay_hp")
- @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses"))
- @selected = false
- @preselected = false
- @switching = false
- @text = nil
- @refreshBitmap = true
- @refreshing = false
- refresh
- end
- end
- def dispose
- @panelbgsprite.dispose
- @hpbgsprite.dispose
- @ballsprite.dispose
- @pkmnsprite.dispose
- @helditemsprite.dispose
- @overlaysprite.bitmap.dispose
- @overlaysprite.dispose
- @hpbar.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.isFainted?; @panelbgsprite.changeBitmap("faintedsel")
- else; @panelbgsprite.changeBitmap("ablesel")
- end
- else
- if self.preselected; @panelbgsprite.changeBitmap("swap")
- elsif @pokemon.isFainted?; @panelbgsprite.changeBitmap("fainted")
- else; @panelbgsprite.changeBitmap("able")
- end
- end
- @panelbgsprite.x = self.x
- @panelbgsprite.y = self.y
- @panelbgsprite.color = self.color
- end
- 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.isFainted?; @hpbgsprite.changeBitmap("fainted")
- else; @hpbgsprite.changeBitmap("able")
- end
- @hpbgsprite.x = self.x+96
- @hpbgsprite.y = self.y+50
- @hpbgsprite.color = self.color
- end
- end
- if @ballsprite && !@ballsprite.disposed?
- @ballsprite.changeBitmap((self.selected) ? "sel" : "desel")
- @ballsprite.x = self.x+10
- @ballsprite.y = self.y
- @ballsprite.color = self.color
- end
- if @pkmnsprite && !@pkmnsprite.disposed?
- @pkmnsprite.x = self.x+28
- @pkmnsprite.y = self.y
- @pkmnsprite.color = self.color
- @pkmnsprite.selected = self.selected
- end
- if @helditemsprite && !@helditemsprite.disposed?
- if @helditemsprite.visible
- @helditemsprite.x = self.x+62
- @helditemsprite.y = self.y+48
- @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 = []
- # 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/Plusoverlay_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
- 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?
- @hpbgsprite.update if @hpbgsprite && !@hpbgsprite.disposed?
- @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)
- if $Trainer.partyplus
- @sprites = {}
- @party = party
- @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z = 99999
- @multiselect = multiselect
- addBackgroundPlane(@sprites,"partybg","Party/Plusbg",@viewport)
- @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
- for i in 0...8
- 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
- if @multiselect
- @sprites["pokemon8"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon9"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon9"] = PokemonPartyCancelSprite.new(@viewport)
- end
- # Select first Pokémon
- @activecmd = 0
- @sprites["pokemon0"].selected = true
- pbFadeInAndShow(@sprites) { update }
- else
- @sprites = {}
- @party = party
- @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport.z = 99999
- @multiselect = multiselect
- addBackgroundPlane(@sprites,"partybg","Party/bg",@viewport)
- @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
- 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
- if @multiselect
- @sprites["pokemon6"] = PokemonPartyConfirmSprite.new(@viewport)
- @sprites["pokemon7"] = PokemonPartyCancelSprite2.new(@viewport)
- else
- @sprites["pokemon6"] = PokemonPartyCancelSprite.new(@viewport)
- end
- # Select first Pokémon
- @activecmd = 0
- @sprites["pokemon0"].selected = true
- pbFadeInAndShow(@sprites) { update }
- end
- 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
- for i in 0...8
- @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 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)
- if $Trainer.partyplus
- 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
- for i in 0...8
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- pbRefresh
- else
- 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
- for i in 0...6
- @sprites["pokemon#{i}"].preselected = false
- @sprites["pokemon#{i}"].switching = false
- end
- pbRefresh
- end
- end
- def pbClearSwitching
- if $Trainer.partyplus
- for i in 0...8
- @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
- for i in 0...8
- @sprites["pokemon#{i}"].preselected = (switching && i==@activecmd)
- @sprites["pokemon#{i}"].switching = switching
- 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 @activecmd!=oldsel # Changing selection
- pbPlayCursorSE
- numsprites = (@multiselect) ? 9 : 8
- for i in 0...numsprites
- @sprites["pokemon#{i}"].selected = (i==@activecmd)
- end
- end
- cancelsprite = (@multiselect) ? 9 : 8
- 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
- else
- for i in 0...6
- @sprites["pokemon#{i}"].preselected = (switching && i==@activecmd)
- @sprites["pokemon#{i}"].switching = switching
- 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 @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
- 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
- end
- def pbChangeSelection(key,currentsel)
- if $Trainer.partyplus
- 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
- return currentsel
- 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
- return currentsel
- end
- end
- def pbHardRefresh
- if $Trainer.partyplus
- oldtext = []
- lastselected = -1
- for i in 0...8
- 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...8
- 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
- for i in 0...8
- 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
- #===============================================================================
- # Pokémon party mechanics
- #===============================================================================
- class PokemonPartyScreen
- attr_reader :scene
- attr_reader :party
- def initialize(scene,party)
- @scene = scene
- @party = party
- end
- def pbStartScene(helptext,doublebattle,annotations=nil)
- @scene.pbStartScene(@party,helptext,annotations)
- end
- def pbChoosePokemon(helptext=nil)
- @scene.pbSetHelpText(helptext) if helptext
- return @scene.pbChoosePokemon
- end
- def pbPokemonGiveScreen(item)
- @scene.pbStartScene(@party,_INTL("Give to which Pokémon?"))
- pkmnid = @scene.pbChoosePokemon
- ret = false
- if pkmnid>=0
- ret = pbGiveItemToPokemon(item,@party[pkmnid],self,pkmnid)
- end
- pbRefreshSingle(pkmnid)
- @scene.pbEndScene
- return ret
- end
- def pbPokemonGiveMailScreen(mailIndex)
- @scene.pbStartScene(@party,_INTL("Give to which Pokémon?"))
- pkmnid = @scene.pbChoosePokemon
- if pkmnid>=0
- pkmn = @party[pkmnid]
- if pkmn.hasItem? || pkmn.mail
- pbDisplay(_INTL("This Pokémon is holding an item. It can't hold mail."))
- elsif pkmn.egg?
- pbDisplay(_INTL("Eggs can't hold mail."))
- else
- pbDisplay(_INTL("Mail was transferred from the Mailbox."))
- pkmn.mail = $PokemonGlobal.mailbox[mailIndex]
- pkmn.setItem(pkmn.mail.item)
- $PokemonGlobal.mailbox.delete_at(mailIndex)
- pbRefreshSingle(pkmnid)
- end
- end
- @scene.pbEndScene
- end
- def pbEndScene
- @scene.pbEndScene
- end
- def pbUpdate
- @scene.update
- end
- def pbHardRefresh
- @scene.pbHardRefresh
- end
- def pbRefresh
- @scene.pbRefresh
- end
- def pbRefreshSingle(i)
- @scene.pbRefreshSingle(i)
- end
- def pbDisplay(text)
- @scene.pbDisplay(text)
- end
- def pbConfirm(text)
- return @scene.pbDisplayConfirm(text)
- end
- def pbShowCommands(helptext,commands,index=0)
- @scene.pbShowCommands(helptext,commands,index)
- end
- # Checks for identical species
- def pbCheckSpecies(array) # Unused
- for i in 0...array.length
- for j in i+1...array.length
- return false if array[i].species==array[j].species
- end
- end
- return true
- end
- # Checks for identical held items
- def pbCheckItems(array) # Unused
- for i in 0...array.length
- next if !array[i].hasItem?
- for j in i+1...array.length
- return false if array[i].item==array[j].item
- end
- end
- return true
- end
- def pbSwitch(oldid,newid)
- if oldid!=newid
- @scene.pbSwitchBegin(oldid,newid)
- tmp = @party[oldid]
- @party[oldid] = @party[newid]
- @party[newid] = tmp
- @scene.pbSwitchEnd(oldid,newid)
- end
- end
- def pbChooseMove(pokemon,helptext,index=0)
- movenames = []
- for i in pokemon.moves
- break if i.id==0
- if i.totalpp==0
- movenames.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id),i.pp,i.totalpp))
- else
- movenames.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp))
- end
- end
- return @scene.pbShowCommands(helptext,movenames,index)
- end
- def pbRefreshAnnotations(ableProc) # For after using an evolution stone
- annot = []
- for pkmn in @party
- elig = ableProc.call(pkmn)
- annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
- end
- @scene.pbAnnotate(annot)
- end
- def pbClearAnnotations
- @scene.pbAnnotate(nil)
- end
- def pbPokemonMultipleEntryScreenEx(ruleset)
- annot = []
- statuses = []
- ordinals = [
- _INTL("INELIGIBLE"),
- _INTL("NOT ENTERED"),
- _INTL("BANNED"),
- _INTL("FIRST"),
- _INTL("SECOND"),
- _INTL("THIRD"),
- _INTL("FOURTH"),
- _INTL("FIFTH"),
- _INTL("SIXTH")
- ]
- return nil if !ruleset.hasValidTeam?(@party)
- ret = nil
- addedEntry = false
- for i in 0...@party.length
- statuses[i] = (ruleset.isPokemonValid?(@party[i])) ? 1 : 2
- end
- for i in 0...@party.length
- annot[i] = ordinals[statuses[i]]
- end
- @scene.pbStartScene(@party,_INTL("Choose Pokémon and confirm."),annot,true)
- loop do
- realorder = []
- for i in 0...@party.length
- for j in 0...@party.length
- if statuses[j]==i+3
- realorder.push(j)
- break
- end
- end
- end
- for i in 0...realorder.length
- statuses[realorder[i]] = i+3
- end
- for i in 0...@party.length
- annot[i] = ordinals[statuses[i]]
- end
- @scene.pbAnnotate(annot)
- if realorder.length==ruleset.number && addedEntry
- @scene.pbSelect(6)
- end
- @scene.pbSetHelpText(_INTL("Choose Pokémon and confirm."))
- pkmnid = @scene.pbChoosePokemon
- addedEntry = false
- if $Trainer.partyplus
- if pkmnid==8 # Confirm was chosen
- ret = []
- for i in realorder; ret.push(@party[i]); end
- error = []
- break if ruleset.isValid?(ret,error)
- pbDisplay(error[0])
- ret = nil
- end
- else
- if pkmnid==6 # Confirm was chosen
- ret = []
- for i in realorder; ret.push(@party[i]); end
- error = []
- break if ruleset.isValid?(ret,error)
- pbDisplay(error[0])
- ret = nil
- end
- end
- break if pkmnid<0 # Canceled
- cmdEntry = -1
- cmdNoEntry = -1
- cmdSummary = -1
- commands = []
- if (statuses[pkmnid] || 0) == 1
- commands[cmdEntry = commands.length] = _INTL("Entry")
- elsif (statuses[pkmnid] || 0) > 2
- commands[cmdNoEntry = commands.length] = _INTL("No Entry")
- end
- pkmn = @party[pkmnid]
- commands[cmdSummary = commands.length] = _INTL("Summary")
- commands[commands.length] = _INTL("Cancel")
- command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands) if pkmn
- if cmdEntry>=0 && command==cmdEntry
- if realorder.length>=ruleset.number && ruleset.number>0
- pbDisplay(_INTL("No more than {1} Pokémon may enter.",ruleset.number))
- else
- statuses[pkmnid] = realorder.length+3
- addedEntry = true
- pbRefreshSingle(pkmnid)
- end
- elsif cmdNoEntry>=0 && command==cmdNoEntry
- statuses[pkmnid] = 1
- pbRefreshSingle(pkmnid)
- elsif cmdSummary>=0 && command==cmdSummary
- @scene.pbSummary(pkmnid)
- end
- end
- @scene.pbEndScene
- return ret
- end
- end
- #===============================================================================
- # Pokémon party buttons and menu
- #===============================================================================
- class PokemonPartyConfirmCancelSprite < SpriteWrapper
- attr_reader :selected
- def initialize(text,x,y,narrowbox=false,viewport=nil)
- super(viewport)
- @refreshBitmap = true
- @bgsprite = ChangelingSprite.new(0,0,viewport)
- if narrowbox
- @bgsprite.addBitmap("desel","Graphics/Pictures/Party/Plusicon_cancel_narrow")
- @bgsprite.addBitmap("sel","Graphics/Pictures/Party/Plusicon_cancel_narrow_sel")
- else
- @bgsprite.addBitmap("desel","Graphics/Pictures/Party/icon_cancel")
- @bgsprite.addBitmap("sel","Graphics/Pictures/Party/icon_cancel_sel")
- end
- @bgsprite.changeBitmap("desel")
- @overlaysprite = BitmapSprite.new(@bgsprite.bitmap.width,@bgsprite.bitmap.height,viewport)
- @overlaysprite.z = self.z+1
- pbSetSystemFont(@overlaysprite.bitmap)
- @yoffset = 8
- textpos = [[text,56,(narrowbox) ? 2 : 8,2,Color.new(248,248,248),Color.new(40,40,40)]]
- pbDrawTextPositions(@overlaysprite.bitmap,textpos)
- self.x = x
- self.y = y
- end
- def dispose
- @bgsprite.dispose
- @overlaysprite.bitmap.dispose
- @overlaysprite.dispose
- super
- end
- def viewport=(value)
- super
- refresh
- end
- def x=(value)
- super
- refresh
- end
- def y=(value)
- super
- refresh
- end
- def color=(value)
- super
- refresh
- end
- def selected=(value)
- if @selected!=value
- @selected = value
- refresh
- end
- end
- def refresh
- if @bgsprite && !@bgsprite.disposed?
- @bgsprite.changeBitmap((@selected) ? "sel" : "desel")
- @bgsprite.x = self.x
- @bgsprite.y = self.y
- @bgsprite.color = self.color
- end
- if @overlaysprite && !@overlaysprite.disposed?
- @overlaysprite.x = self.x
- @overlaysprite.y = self.y
- @overlaysprite.color = self.color
- end
- end
- end
- class PokemonPartyCancelSprite < PokemonPartyConfirmCancelSprite
- def initialize(viewport=nil)
- super(_INTL("CANCEL"),398,328,false,viewport)
- end
- end
- class PokemonPartyConfirmSprite < PokemonPartyConfirmCancelSprite
- def initialize(viewport=nil)
- super(_INTL("CONFIRM"),398,308,true,viewport)
- end
- end
- class PokemonPartyCancelSprite2 < PokemonPartyConfirmCancelSprite
- def initialize(viewport=nil)
- super(_INTL("CANCEL"),398,346,true,viewport)
- end
- end
- ################################################################################
- # Storage Scene #
- ################################################################################
- #===============================================================================
- # Party pop-up panel
- #===============================================================================
- class PokemonBoxPartySprite < SpriteWrapper
- def initialize(party,viewport=nil)
- if $Trainer.partyplus
- super(viewport)
- @party = party
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_partyplus")
- @pokemonsprites = []
- for i in 0...8
- @pokemonsprites[i] = nil
- pokemon = @party[i]
- if pokemon
- @pokemonsprites[i] = PokemonBoxIcon.new(pokemon,viewport)
- end
- end
- @contents = BitmapWrapper.new(172,352)
- self.bitmap = @contents
- self.x = 182
- self.y = Graphics.height-352
- pbSetSystemFont(self.bitmap)
- refresh
- else
- super(viewport)
- @party = party
- @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_party")
- @pokemonsprites = []
- for i in 0...6
- @pokemonsprites[i] = nil
- pokemon = @party[i]
- if pokemon
- @pokemonsprites[i] = PokemonBoxIcon.new(pokemon,viewport)
- end
- end
- @contents = BitmapWrapper.new(172,352)
- self.bitmap = @contents
- self.x = 182
- self.y = Graphics.height-352
- pbSetSystemFont(self.bitmap)
- refresh
- end
- end
- def dispose
- if $Trainer.partyplus
- for i in 0...8
- @pokemonsprites[i].dispose if @pokemonsprites[i]
- end
- @boxbitmap.dispose
- @contents.dispose
- super
- else
- for i in 0...6
- @pokemonsprites[i].dispose if @pokemonsprites[i]
- end
- @boxbitmap.dispose
- @contents.dispose
- super
- end
- end
- def x=(value)
- super
- refresh
- end
- def y=(value)
- super
- refresh
- end
- def color=(value)
- if $Trainer.partyplus
- super
- for i in 0...8
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color,value)
- end
- end
- else
- super
- 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)
- if $Trainer.partyplus
- super
- for i in 0...8
- if @pokemonsprites[i] && !@pokemonsprites[i].disposed?
- @pokemonsprites[i].visible = value
- end
- end
- else
- super
- 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
- @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,352))
- pbDrawTextPositions(self.bitmap,[
- [_INTL("Back"),86,306,2,Color.new(248,248,248),Color.new(80,80,80),1]
- ])
- xvalues = [18,90,18,90,18,90,18,90]
- yvalues = [2,18,66,82,130,146,194,210]
- for j in 0...8
- @pokemonsprites[j] = nil if @pokemonsprites[j] && @pokemonsprites[j].disposed?
- end
- @pokemonsprites.compact!
- for j in 0...8
- 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
- @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]
- 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
- for i in 0...8
- @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
- @sprites["boxparty"].x = 182
- @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 $Trainer.partyplus
- if selection>=0
- xvalues = [100,136,100,136,100,136,100,136,118]
- yvalues = [1,9,33,41,65,73,97,105,142]
- arrow.angle = 0
- arrow.mirror = false
- arrow.ox = 0
- arrow.oy = 0
- arrow.x = xvalues[selection]*2
- arrow.y = yvalues[selection]*2
- end
- else
- if selection>=0
- xvalues = [100,136,100,136,100,136,118]
- yvalues = [1,9,33,41,65,73,110]
- arrow.angle = 0
- arrow.mirror = false
- arrow.ox = 0
- arrow.oy = 0
- arrow.x = xvalues[selection]*2
- arrow.y = yvalues[selection]*2
- end
- end
- end
- def pbPartyChangeSelection(key,selection)
- if $Trainer.partyplus
- 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
- return selection
- 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
- return selection
- end
- 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)
- if $Trainer.partyplus
- 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 selection>=0 && selection<8
- @selection = selection
- return selection
- elsif selection==8 # Close Box
- @selection = selection
- return (depositing) ? -3 : -1
- end
- end
- end
- else
- 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 selection>=0 && selection<6
- @selection = selection
- return selection
- elsif selection==6 # Close Box
- @selection = selection
- return (depositing) ? -3 : -1
- end
- end
- end
- end
- end
- end
- ################################################################################
- # Pc #
- ################################################################################
- 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
- if $Trainer.partyplus
- 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 $PokemonStorage.party.length>=8
- Kernel.pbMessage(_INTL("Your party is full!"))
- next
- 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
- else
- 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 $PokemonStorage.party.length>=6
- Kernel.pbMessage(_INTL("Your party is full!"))
- next
- 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
- end
- ################################################################################
- # OrgBattle #
- ################################################################################
- def pbBattleFactoryPokemon(rule,numwins,numswaps,rentals)
- if $Trainer.partyplus
- 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
- 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 until rule.ruleset.isValid?(party)
- return party
- else
- 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
- 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 until rule.ruleset.isValid?(party)
- return party
- end
- end
- ################################################################################
- # PokemonUtilities #
- ################################################################################
- #===============================================================================
- # Nicknaming and storing Pokémon
- #===============================================================================
- def pbBoxesFull?
- if $Trainer.partyplus
- return !$Trainer || ($Trainer.party.length==8 && $PokemonStorage.full?)
- else
- return !$Trainer || ($Trainer.party.length==6 && $PokemonStorage.full?)
- end
- end
- def pbNickname(pokemon)
- speciesname = PBSpecies.getName(pokemon.species)
- if Kernel.pbConfirmMessage(_INTL("Would you like to give a nickname to {1}?",speciesname))
- helptext = _INTL("{1}'s nickname?",speciesname)
- newname = pbEnterPokemonName(helptext,0,PokeBattle_Pokemon::NAMELIMIT,"",pokemon)
- pokemon.name = newname if newname!=""
- end
- end
- def pbStorePokemon(pokemon)
- if $Trainer.partyplus
- 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.party.length<8
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- monsent=false
- while !monsent
- if Kernel.pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
- iMon = -2
- eggcount = 0
- for i in $Trainer.party
- next if i.isEgg?
- eggcount += 1
- end
- pbFadeOutIn(99999){
- sscene = PokemonParty_Scene.new
- sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
- sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
- loop do
- iMon=sscreen.pbChoosePokemon
- if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
- Kernel.pbMessage("That's your last Pokémon!")
- else
- sscreen.pbEndScene
- break
- end
- end
- }
- if !(iMon < 0)
- iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
- if iBox >= 0
- monsent=true
- $Trainer.party[iMon].heal
- Kernel.pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
- $Trainer.party[iMon] = nil
- $Trainer.party.compact!
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- Kernel.pbMessage("No space left in the PC")
- return false
- end
- end
- else
- monsent=true
- 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
- else
- 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.party.length<6
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- monsent=false
- while !monsent
- if Kernel.pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
- iMon = -2
- eggcount = 0
- for i in $Trainer.party
- next if i.isEgg?
- eggcount += 1
- end
- pbFadeOutIn(99999){
- sscene = PokemonParty_Scene.new
- sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
- sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
- loop do
- iMon=sscreen.pbChoosePokemon
- if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
- Kernel.pbMessage("That's your last Pokémon!")
- else
- sscreen.pbEndScene
- break
- end
- end
- }
- if !(iMon < 0)
- iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
- if iBox >= 0
- monsent=true
- $Trainer.party[iMon].heal
- Kernel.pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
- $Trainer.party[iMon] = nil
- $Trainer.party.compact!
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- Kernel.pbMessage("No space left in the PC")
- return false
- end
- end
- else
- monsent=true
- 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
- end
- end
- def pbNicknameAndStore(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
- $Trainer.seen[pokemon.species] = true
- $Trainer.owned[pokemon.species] = true
- pbNickname(pokemon)
- pbStorePokemon(pokemon)
- end
- #===============================================================================
- # Giving Pokémon to the player (will send to storage if party is full)
- #===============================================================================
- def pbAddPokemon(pokemon,level=nil,seeform=true)
- return if !pokemon || !$Trainer
- 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 false
- 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 pbAddPokemonSilent(pokemon,level=nil,seeform=true)
- if $Trainer.partyplus
- 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
- if pokemon.ot == ""
- pokemon.ot = $Trainer.name
- pokemon.trainerID = $Trainer.id
- end
- $Trainer.seen[pokemon.species]=true
- $Trainer.owned[pokemon.species]=true
- pbSeenForm(pokemon) if seeform
- pokemon.pbRecordFirstMoves
- if $Trainer.party.length<8
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- monsent=false
- while !monsent
- if Kernel.pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
- iMon = -2
- eggcount = 0
- for i in $Trainer.party
- next if i.isEgg?
- eggcount += 1
- end
- pbFadeOutIn(99999){
- sscene = PokemonParty_Scene.new
- sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
- sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
- loop do
- iMon=sscreen.pbChoosePokemon
- if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
- Kernel.pbMessage("That's your last Pokémon!")
- else
- sscreen.pbEndScene
- break
- end
- end
- }
- if !(iMon < 0)
- iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
- if iBox >= 0
- monsent=true
- Kernel.pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
- $Trainer.party[iMon] = nil
- $Trainer.party.compact!
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- Kernel.pbMessage("No space left in the PC.")
- return false
- end
- end
- else
- monsent=true
- storedbox = $PokemonStorage.pbStoreCaught(pokemon)
- if pokemon.isEgg?
- 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
- end
- return true
- else
- 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
- if pokemon.ot == ""
- pokemon.ot = $Trainer.name
- pokemon.trainerID = $Trainer.id
- end
- $Trainer.seen[pokemon.species]=true
- $Trainer.owned[pokemon.species]=true
- pbSeenForm(pokemon) if seeform
- pokemon.pbRecordFirstMoves
- if $Trainer.party.length<6
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- monsent=false
- while !monsent
- if Kernel.pbConfirmMessageSerious(_INTL("The party is full; do you want to send someone to the PC?"))
- iMon = -2
- eggcount = 0
- for i in $Trainer.party
- next if i.isEgg?
- eggcount += 1
- end
- pbFadeOutIn(99999){
- sscene = PokemonParty_Scene.new
- sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
- sscreen.pbStartScene(_INTL("Choose a Pokémon."),false)
- loop do
- iMon=sscreen.pbChoosePokemon
- if eggcount<=1 && !($Trainer.party[iMon].isEgg?) && pokemon.isEgg?
- Kernel.pbMessage("That's your last Pokémon!")
- else
- sscreen.pbEndScene
- break
- end
- end
- }
- if !(iMon < 0)
- iBox = $PokemonStorage.pbStoreCaught($Trainer.party[iMon])
- if iBox >= 0
- monsent=true
- Kernel.pbMessage(_INTL("{1} was sent to {2}.", $Trainer.party[iMon].name, $PokemonStorage[iBox].name))
- $Trainer.party[iMon] = nil
- $Trainer.party.compact!
- $Trainer.party[$Trainer.party.length]=pokemon
- else
- Kernel.pbMessage("No space left in the PC.")
- return false
- end
- end
- else
- monsent=true
- storedbox = $PokemonStorage.pbStoreCaught(pokemon)
- if pokemon.isEgg?
- 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
- end
- return true
- end
- end
- #===============================================================================
- # Giving Pokémon/eggs to the player (can only add to party)
- #===============================================================================
- def pbAddToParty(pokemon,level=nil,seeform=true)
- if $Trainer.partyplus
- return false if !pokemon || !$Trainer || $Trainer.party.length>=8
- 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
- return false if !pokemon || !$Trainer || $Trainer.party.length>=8
- 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
- return false if !pokemon || !$Trainer || $Trainer.party.length>=8
- 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
- return false if !pokemon || !$Trainer || $Trainer.party.length>=8
- 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
- def pbAddEgg(pokemon,text="")
- return pbGenerateEgg(pokemon,text)
- end
- ################################################################################
- # Utilities #
- ################################################################################
- #===============================================================================
- # Other utilities
- #===============================================================================
- def pbTextEntry(helptext,minlength,maxlength,variableNumber)
- $game_variables[variableNumber] = pbEnterText(helptext,minlength,maxlength)
- $game_map.need_refresh = true if $game_map
- end
- def pbMoveTutorAnnotations(move,movelist=nil)
- if $Trainer.partyplus
- ret = []
- for i in 0...8
- 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
- ret = []
- 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: $#{pbDayCareCost(i)}",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
- case cmdwindow.index
- when 0 # Withdraw Pokémon 1
- if $Trainer.partyplus
- if !$PokemonGlobal.daycare[0][0]
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=8
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
- else
- pbPlayDecisionSE
- pbDayCareGetDeposited(0,3,4)
- pbDayCareWithdraw(0)
- refresh = true
- end
- else
- 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
- end
- when 1 # Withdraw Pokémon 2
- if $Trainer.partyplus
- if !$PokemonGlobal.daycare[1][0]
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=8
- pbPlayBuzzerSE
- Kernel.pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
- else
- pbPlayDecisionSE
- pbDayCareGetDeposited(1,3,4)
- pbDayCareWithdraw(1)
- refresh = true
- end
- else
- 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
- 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 $Trainer.partyplus
- if $PokemonGlobal.daycareEgg!=1
- pbPlayBuzzerSE
- elsif $Trainer.party.length>=8
- 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
- else
- 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
- # For demonstration purposes only, not to be used in a real game.
- def pbCreatePokemon
- pbRemovePokemonAt(7)
- pbRemovePokemonAt(6)
- if $Trainer.partyplus
- party = []
- species = [:JOLTEON,:TOGETIC,:MONFERNO,:GYARADOS,:DIGLETT,:AMBIPOM,:PRINPLUP,:GROTLE]
- for id in species
- party.push(getConst(PBSpecies,id)) if hasConst?(PBSpecies,id)
- end
- # Species IDs of the Pokémon to be created
- for i in 0...party.length
- species = party[i]
- # Generate Pokémon with species and level 20
- $Trainer.party[i] = PokeBattle_Pokemon.new(species,20,$Trainer)
- $Trainer.seen[species] = true # Set this species to seen and owned
- $Trainer.owned[species] = true
- pbSeenForm($Trainer.party[i])
- end
- $Trainer.party[1].pbLearnMove(:FLY)
- $Trainer.party[2].pbLearnMove(:FLASH)
- $Trainer.party[2].pbLearnMove(:TELEPORT)
- $Trainer.party[3].pbLearnMove(:SURF)
- $Trainer.party[3].pbLearnMove(:DIVE)
- $Trainer.party[3].pbLearnMove(:WATERFALL)
- $Trainer.party[4].pbLearnMove(:DIG)
- $Trainer.party[4].pbLearnMove(:CUT)
- $Trainer.party[4].pbLearnMove(:HEADBUTT)
- $Trainer.party[4].pbLearnMove(:ROCKSMASH)
- $Trainer.party[5].pbLearnMove(:SOFTBOILED)
- $Trainer.party[5].pbLearnMove(:STRENGTH)
- $Trainer.party[5].pbLearnMove(:SWEETSCENT)
- for i in 0...party.length
- $Trainer.party[i].pbRecordFirstMoves
- end
- else
- party = []
- species = [:JOLTEON,:TOGETIC,:MONFERNO,:GYARADOS,:DIGLETT,:AMBIPOM]
- for id in species
- party.push(getConst(PBSpecies,id)) if hasConst?(PBSpecies,id)
- end
- # Species IDs of the Pokémon to be created
- for i in 0...party.length
- species = party[i]
- # Generate Pokémon with species and level 20
- $Trainer.party[i] = PokeBattle_Pokemon.new(species,20,$Trainer)
- $Trainer.seen[species] = true # Set this species to seen and owned
- $Trainer.owned[species] = true
- pbSeenForm($Trainer.party[i])
- end
- $Trainer.party[1].pbLearnMove(:FLY)
- $Trainer.party[2].pbLearnMove(:FLASH)
- $Trainer.party[2].pbLearnMove(:TELEPORT)
- $Trainer.party[3].pbLearnMove(:SURF)
- $Trainer.party[3].pbLearnMove(:DIVE)
- $Trainer.party[3].pbLearnMove(:WATERFALL)
- $Trainer.party[4].pbLearnMove(:DIG)
- $Trainer.party[4].pbLearnMove(:CUT)
- $Trainer.party[4].pbLearnMove(:HEADBUTT)
- $Trainer.party[4].pbLearnMove(:ROCKSMASH)
- $Trainer.party[5].pbLearnMove(:SOFTBOILED)
- $Trainer.party[5].pbLearnMove(:STRENGTH)
- $Trainer.party[5].pbLearnMove(:SWEETSCENT)
- for i in 0...party.length
- $Trainer.party[i].pbRecordFirstMoves
- end
- end
- end
- ################################################################################
- # PBS Alterations #
- ################################################################################
- 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("First Pokémon.")],
- [_INTL("Pokémon 2"),TrainerPokemonProperty,_INTL("Second Pokémon.")],
- [_INTL("Pokémon 3"),TrainerPokemonProperty,_INTL("Third Pokémon.")],
- [_INTL("Pokémon 4"),TrainerPokemonProperty,_INTL("Fourth Pokémon.")],
- [_INTL("Pokémon 5"),TrainerPokemonProperty,_INTL("Fifth Pokémon.")],
- [_INTL("Pokémon 6"),TrainerPokemonProperty,_INTL("Sixth Pokémon.")],
- [_INTL("Pokémon 7"),TrainerPokemonProperty,_INTL("Seventh Pokémon.")],
- [_INTL("Pokémon 8"),TrainerPokemonProperty,_INTL("Eigth 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
- trainerdata[1], # Trainer name
- trainerdata[4], # ID
- trainerdata[3][0], # Pokémon 1
- trainerdata[3][1], # Pokémon 2
- trainerdata[3][2], # Pokémon 3
- trainerdata[3][3], # Pokémon 4
- trainerdata[3][4], # Pokémon 5
- trainerdata[3][5], # Pokémon 6
- trainerdata[3][6], # Pokémon 7
- trainerdata[3][7], # Pokémon 8
- 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[9],data[10],data[11],data[12],data[13],data[14],data[15],data[16]].find_all {|i| i && i!=0 }, # Item list
- [data[3],data[4],data[5],data[6],data[7],data[8]].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
- ################################################################################
- # Storaage Inprovements #
- ################################################################################
- class PokemonBox
- attr_reader :pokemon
- attr_accessor :name
- attr_accessor :background
- def initialize(name,maxPokemon=30)
- @pokemon = []
- @name = name
- @background = 0
- for i in 0...maxPokemon
- @pokemon[i] = nil
- end
- end
- def length
- return @pokemon.length
- end
- def nitems
- return @pokemon.nitems
- end
- def full?
- return (@pokemon.nitems==self.length)
- end
- def empty?
- return (@pokemon.nitems==0)
- end
- def [](i)
- return @pokemon[i]
- end
- def []=(i,value)
- @pokemon[i] = value
- end
- def each
- @pokemon.each{|item| yield item}
- end
- def clear
- @pokemon.clear
- end
- end
- 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)
- if $Trainer.partyplus
- return 0 if box>=self.maxBoxes
- return (box<0) ? 8 : self[box].length
- else
- return 0 if box>=self.maxBoxes
- return (box<0) ? 6 : self[box].length
- end
- end
- def full?
- for i in 0...self.maxBoxes
- return false if !@boxes[i].full?
- end
- return true
- end
- def pbFirstFreePos(box)
- if $Trainer.partyplus
- if box==-1
- ret = self.party.nitems
- return (ret==8) ? -1 : ret
- else
- for i in 0...maxPokemon(box)
- return i if !self[box,i]
- end
- return -1
- end
- else
- 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
- 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 $Trainer.partyplus
- 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
- return false if self.party.nitems>=8
- 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
- else
- 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
- return false if self.party.nitems>=6
- 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
- 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
- return false if self.party.nitems>=8
- self.party[self.party.length] = pkmn
- else
- return false if self.party.nitems>=6
- self.party[self.party.length] = pkmn
- end
- 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
- #===============================================================================
- # Regional Storage scripts
- #===============================================================================
- class RegionalStorage
- def initialize
- @storages = []
- @lastmap = -1
- @rgnmap = -1
- end
- def getCurrentStorage
- if !$game_map
- raise _INTL("The player is not on a map, so the region could not be determined.")
- end
- if @lastmap!=$game_map.map_id
- @rgnmap = pbGetCurrentRegion # may access file IO, so caching result
- @lastmap = $game_map.map_id
- end
- if @rgnmap<0
- raise _INTL("The current map has no region set. Please set the MapPosition metadata setting for this map.")
- end
- if !@storages[@rgnmap]
- @storages[@rgnmap] = PokemonStorage.new
- end
- return @storages[@rgnmap]
- end
- def allWallpapers
- return getCurrentStorage.allWallpapers
- end
- def availableWallpapers
- return getCurrentStorage.availableWallpapers
- end
- def unlockWallpaper(index)
- getCurrentStorage.unlockWallpaper(index)
- end
- def boxes
- return getCurrentStorage.boxes
- end
- def party
- return getCurrentStorage.party
- end
- def maxBoxes
- return getCurrentStorage.maxBoxes
- end
- def maxPokemon(box)
- return getCurrentStorage.maxPokemon(box)
- end
- def full?
- getCurrentStorage.full?
- end
- def currentBox
- return getCurrentStorage.currentBox
- end
- def currentBox=(value)
- getCurrentStorage.currentBox = value
- end
- def [](x,y=nil)
- getCurrentStorage[x,y]
- end
- def []=(x,y,value)
- getCurrentStorage[x,y] = value
- end
- def pbFirstFreePos(box)
- getCurrentStorage.pbFirstFreePos(box)
- end
- def pbCopy(boxDst,indexDst,boxSrc,indexSrc)
- getCurrentStorage.pbCopy(boxDst,indexDst,boxSrc,indexSrc)
- end
- def pbMove(boxDst,indexDst,boxSrc,indexSrc)
- getCurrentStorage.pbCopy(boxDst,indexDst,boxSrc,indexSrc)
- end
- def pbMoveCaughtToParty(pkmn)
- getCurrentStorage.pbMoveCaughtToParty(pkmn)
- end
- def pbMoveCaughtToBox(pkmn,box)
- getCurrentStorage.pbMoveCaughtToBox(pkmn,box)
- end
- def pbStoreCaught(pkmn)
- getCurrentStorage.pbStoreCaught(pkmn)
- end
- def pbDelete(box,index)
- getCurrentStorage.pbDelete(pkmn)
- end
- end
- #===============================================================================
- #
- #===============================================================================
- def pbUnlockWallpaper(index)
- $PokemonStorage.unlockedWallpapers[index] = true
- end
- def pbLockWallpaper(index) # Don't know why you'd want to do this
- $PokemonStorage.unlockedWallpapers[index] = false
- end
- #===============================================================================
- # Battle Party
- #===============================================================================
- class PokeBattle_DebugScene
- def initialize
- @battle=nil
- @lastcmd=[0,0,0,0]
- @lastmove=[0,0,0,0]
- @pkmnwindows=[nil,nil,nil,nil]
- end
- def pbDisplayMessage(msg,brief=false)
- pbRefresh
- cw = Window_SimpleText.new(msg,4)
- cw.y=256
- i=0
- loop do
- Graphics.update
- Input.update
- cw.update
- if i==80
- cw.dispose
- return
- end
- if Input.trigger?(Input::C)
- cw.dispose
- return
- end
- i+=1
- end
- end
- def pbDisplayPausedMessage(msg)
- cw = Window_SimpleText.new(msg,4)
- cw.y=256
- cw.pause=true
- loop do
- Graphics.update
- Input.update
- cw.update
- if Input.trigger?(Input::C)
- cw.dispose
- return
- end
- end
- end
- def pbDisplayConfirmMessage(msg)
- dw = Window_SimpleText.new(msg,4)
- dw.y=256
- commands=["YES","NO"]
- cw = Window_Command.new(96, commands)
- cw.x=384
- cw.y=160
- cw.index=0
- pbRefresh
- loop do
- Graphics.update
- Input.update
- pbFrameUpdate(cw)
- if Input.trigger?(Input::B)
- cw.dispose
- dw.dispose
- return false
- end
- if Input.trigger?(Input::C)
- cw.dispose
- dw.dispose
- return (cw.index==0)?true:false
- end
- end
- end
- def pbFrameUpdate(cw)
- cw.update if cw
- for i in 0..3
- @pkmnwindows[i].update if @pkmnwindows[i]
- end
- # @exceptwindow.text="Exceptions: #{$PBDebugExceptions}"
- # @exceptwindow.update
- end
- def pbRefresh
- for i in 0..3
- @pkmnwindows[i].refresh if @pkmnwindows[i]
- end
- # @exceptwindow.refresh
- end
- # Called whenever a new round begins.
- def pbBeginCommandPhase
- end
- # Called whenever the battle begins
- def pbStartBattle(battle)
- @battle=battle
- @lastcmd=[0,0,0,0]
- @lastmove=[0,0,0,0]
- numwindows=battle.doublebattle ? 4 : 2
- for i in 0...numwindows
- @pkmnwindows[i]=Window_Pokemon.new(@battle.battlers[i])
- @pkmnwindows[i].y=i*64
- end
- # @exceptwindow=Window_SimpleText.new("Exceptions: 0",1)
- # @exceptwindow.x=0
- # @exceptwindow.y=416
- end
- def pbEndBattle(result)
- for i in 0..3
- @pkmnwindows[i].dispose if @pkmnwindows[i]
- end
- # @exceptwindow.dispose
- end
- def pbTrainerSendOut(battle,pkmn)
- pbRefresh
- end
- def pbSendOut(battle,pkmn)
- pbRefresh
- end
- def pbTrainerWithdraw(battle,pkmn)
- pbRefresh
- end
- def pbWithdraw(battle,pkmn)
- pbRefresh
- 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(pkmn,move)
- return 0
- end
- def pbBeginAttackPhase
- end
- # Use this method to display the list of commands.
- # Return values:
- # 0 - Fight
- # 1 - Pokémon
- # 2 - Bag
- # 3 - Run
- def pbCommandMenu(index)
- commands=["FIGHT","POKéMON","BAG","RUN"]
- cw = Window_Command.new(192, commands)
- cw.x=0
- cw.y=256
- cw.index=@lastcmd[index]
- pbRefresh
- loop do
- Graphics.update
- Input.update
- pbFrameUpdate(cw)
- if Input.trigger?(Input::C)
- ret=cw.index
- cw.dispose
- @lastcmd[index]=ret
- return ret
- end
- end
- end
- def pbPokemonString(pkmn)
- status=""
- if pkmn.hp<=0
- status=" [FNT]"
- else
- case pkmn.status
- when PBStatuses::SLEEP
- status=" [SLP]"
- when PBStatuses::FROZEN
- status=" [FRZ]"
- when PBStatuses::BURN
- status=" [BRN]"
- when PBStatuses::PARALYSIS
- status=" [PAR]"
- when PBStatuses::POISON
- status=" [PSN]"
- end
- end
- return "#{pkmn.name} (Lv. #{pkmn.level})#{status} HP: #{pkmn.hp}/#{pkmn.totalhp}"
- end
- def pbMoveString(move)
- ret="#{move.name}"
- typename=PBTypes.getName(move.type)
- if move.id>0
- ret+=" (#{typename}) PP: #{move.pp}/#{move.totalpp}"
- end
- return ret
- end
- # Use this method to display the list of moves for a Pokémon
- def pbFightMenu(index)
- moves=@battle.battlers[index].moves
- commands=[
- pbMoveString(moves[0]),
- pbMoveString(moves[1]),
- pbMoveString(moves[2]),
- pbMoveString(moves[3])
- ]
- cw = Window_Command.new(480, commands)
- cw.x=0
- cw.y=256
- cw.index=@lastmove[index]
- pbRefresh
- loop do
- Graphics.update
- Input.update
- pbFrameUpdate(cw)
- if Input.trigger?(Input::B)
- @lastmove[index]=cw.index
- cw.dispose
- return -1
- end
- if Input.trigger?(Input::C)
- ret=cw.index
- @lastmove[index]=ret
- cw.dispose
- return ret
- end
- end
- end
- def pbResetMoveIndex(index)
- 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)
- pbDisplayMessage("Items can't be used here.")
- return -1
- end
- def pbFirstTarget(index,targettype)
- for i in 0...4
- if i!=index && !@battle.battlers[i].isFainted?
- return i
- end
- end
- return -1
- end
- def pbNextTarget(cur,index)
- return -1 if cur>=3
- for i in cur+1..3
- if i!=index && !@battle.battlers[i].isFainted?
- return i
- end
- end
- return -1
- end
- def pbPrevTarget(cur,index)
- return -1 if cur<=0
- ret=-1
- for i in 0..cur-1
- if i!=index && !@battle.battlers[i].isFainted?
- ret=i
- end
- end
- return ret
- end
- # Use this method to make the player choose a target
- # for certain moves in double battles.
- def pbChooseTarget(index,targettype)
- curwindow=pbFirstTarget(index,targettype)
- if curwindow==-1
- raise RuntimeError.new("No targets somehow...")
- end
- numwindows=@battle.doublebattle ? 4 : 2
- for i in 0...numwindows
- @pkmnwindows[i].highlighted=(i==curwindow)
- end
- pbRefresh
- loop do
- Graphics.update
- Input.update
- pbFrameUpdate(nil)
- if Input.trigger?(Input::DOWN)
- newwindow=pbNextTarget(curwindow,index)
- if newwindow>=0
- curwindow=newwindow
- for i in 0...numwindows
- @pkmnwindows[i].highlighted=(i==curwindow)
- end
- end
- end
- if Input.trigger?(Input::UP)
- newwindow=pbPrevTarget(curwindow,index)
- if newwindow>=0
- curwindow=newwindow
- for i in 0...numwindows
- @pkmnwindows[i].highlighted=(i==curwindow)
- end
- end
- end
- if Input.trigger?(Input::B)
- for i in 0...numwindows
- @pkmnwindows[i].highlighted=false
- @pkmnwindows[i].update
- end
- return -1
- end
- if Input.trigger?(Input::C)
- for i in 0...numwindows
- @pkmnwindows[i].highlighted=false
- @pkmnwindows[i].update
- end
- return curwindow
- end
- end
- end
- def pbSwitch(index,lax,cancancel)
- party=@battle.pbParty(index)
- commands=[]
- inactives=[1,1,1,1,1,1,1,1]
- partypos=[]
- activecmd=0
- numactive=(@doublebattle)?2:1
- battler=@battle.battlers[0]
- commands[commands.length]=pbPokemonString(party[battler.pokemonIndex])
- activecmd=0 if battler.index==index
- inactives[battler.pokemonIndex]=0
- partypos[partypos.length]=battler.pokemonIndex
- if @battle.doublebattle
- battler=@battle.battlers[2]
- commands[commands.length]=pbPokemonString(party[battler.pokemonIndex])
- activecmd=1 if battler.index==index
- inactives[battler.pokemonIndex]=0
- partypos[partypos.length]=battler.pokemonIndex
- end
- for i in 0..party.length-1
- if inactives[i]==1
- commands[commands.length]=pbPokemonString(party[i])
- partypos[partypos.length]=i
- end
- end
- for i in 0..4
- @pkmnwindows[i].visible=false if @pkmnwindows[i]
- end
- cw = Window_Command.new(480, commands)
- cw.x=0
- cw.y=0
- cw.index=activecmd
- pbRefresh
- ret=0
- loop do
- Graphics.update
- Input.update
- pbFrameUpdate(cw)
- if cancancel && Input.trigger?(Input::B)
- ret=-1
- cw.dispose
- break
- end
- if Input.trigger?(Input::C)
- pkmnindex=partypos[cw.index]
- canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex,true) :
- @battle.pbCanSwitch?(index,pkmnindex,true)
- if canswitch
- ret=pkmnindex
- cw.dispose
- break
- end
- end
- end
- for i in 0..4
- @pkmnwindows[i].visible=true if @pkmnwindows[i]
- end
- return ret
- end
- # This method is called whenever a Pokémon's HP changes.
- # Used to animate the HP bar.
- def pbHPChanged(pkmn,oldhp,anim=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
- pbRefresh
- end
- # This method is called whenever a Pokémon faints
- def pbFainted(pkmn)
- end
- 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
- end
- # This method is called when the player wins a Trainer battle.
- # This method can change the battle's music for example.
- def pbTrainerBattleSuccess
- end
- def pbEXPBar(battler,thispoke,startexp,endexp,tempexp1,tempexp2)
- end
- def pbLevelUp(battler,thispoke,oldtotalhp,oldattack,
- olddefense,oldspeed,oldspatk,oldspdef)
- end
- def pbShowOpponent(opp)
- end
- def pbHideOpponent
- end
- def pbRecall(battlerindex)
- end
- def pbDamageAnimation(pkmn,effectiveness)
- end
- def pbAnimation(moveid,attacker,opponent,hitnum=0)
- if attacker
- if opponent
- PBDebug.log("[pbAnimation] #{attacker.pbThis}, #{opponent.pbThis}")
- else
- PBDebug.log("[pbAnimation] #{attacker.pbThis}")
- end
- else
- PBDebug.log("[pbAnimation]")
- 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
- if $Trainer.partyplus
- for i in 0...othertrainer.party.length
- combinedParty[8+i] = othertrainer.party[i]
- end
- else
- for i in 0...othertrainer.party.length
- combinedParty[6+i] = othertrainer.party[i]
- end
- 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 $Trainer.partyplus
- 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<=8
- $PokemonTemp.waitingTrainer=[trainer,thisEvent.id,endspeech]
- return false
- end
- end
- end
- else
- 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<=6
- $PokemonTemp.waitingTrainer=[trainer,thisEvent.id,endspeech]
- return false
- end
- 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
- if $Trainer.partyplus
- for i in 0...othertrainer.party.length
- playerparty[8+i] = othertrainer.party[i]
- end
- else
- for i in 0...othertrainer.party.length
- playerparty[6+i] = othertrainer.party[i]
- end
- 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
- if $Trainer.partyplus
- for i in 0...trainer[2].length
- combinedParty[8+i] = trainer[2][i]
- end
- else
- for i in 0...trainer[2].length
- combinedParty[6+i] = trainer[2][i]
- end
- end
- fullparty2 = true
- else
- for i in 0...$PokemonTemp.waitingTrainer[0][2].length
- combinedParty[i] = $PokemonTemp.waitingTrainer[0][2][i]
- end
- if $Trainer.partyplus
- for i in 0...trainer[2].length
- combinedParty[4+i] = trainer[2][i]
- end
- else
- for i in 0...trainer[2].length
- combinedParty[3+i] = trainer[2][i]
- end
- 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
- if $Trainer.partyplus
- for i in 0...othertrainer.party.length
- playerparty[8+i] = othertrainer.party[i]
- end
- else
- for i in 0...othertrainer.party.length
- playerparty[6+i] = othertrainer.party[i]
- end
- 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
- if $Trainer.partyplus
- for i in 0...trainer2[2].length
- combinedParty[8+i] = trainer2[2][i]
- end
- else
- for i in 0...trainer2[2].length
- combinedParty[6+i] = trainer2[2][i]
- end
- 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
- #===============================================================================
- # After battles
- #===============================================================================
- def pbAfterBattle(decision,canlose)
- for i in $Trainer.party
- (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil)
- end
- if $PokemonGlobal.partner
- pbHealAll
- for i in $PokemonGlobal.partner[3]
- i.heal
- (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil)
- end
- end
- if decision==2 || decision==5 # if loss or draw
- if canlose
- for i in $Trainer.party; i.heal; end
- for i in 0...10
- Graphics.update
- end
- end
- end
- Events.onEndBattle.trigger(nil,decision,canlose)
- end
- Events.onEndBattle+=proc {|sender,e|
- decision = e[0]
- canlose = e[1]
- if USENEWBATTLEMECHANICS || (decision!=2 && decision!=5) # not a loss or a draw
- if $PokemonTemp.evolutionLevels
- pbEvolutionCheck($PokemonTemp.evolutionLevels)
- $PokemonTemp.evolutionLevels = nil
- end
- end
- if decision==1
- for pkmn in $Trainer.pokemonParty
- Kernel.pbPickup(pkmn)
- if isConst?(pkmn.ability,PBAbilities,:HONEYGATHER) && !pkmn.hasItem?
- if hasConst?(PBItems,:HONEY)
- chance = 5+((pkmn.level-1)/10).floor*5
- pkmn.setItem(:HONEY) if rand(100)<chance
- end
- end
- end
- end
- if (decision==2 || decision==5) && !canlose
- $game_system.bgm_unpause
- $game_system.bgs_unpause
- Kernel.pbStartOver
- end
- }
- def pbEvolutionCheck(currentlevels)
- for i in 0...currentlevels.length
- pokemon = $Trainer.party[i]
- next if pokemon.hp==0 && !USENEWBATTLEMECHANICS
- if pokemon && (!currentlevels[i] || pokemon.level!=currentlevels[i])
- newspecies = Kernel.pbCheckEvolution(pokemon)
- if newspecies>0
- evo = PokemonEvolutionScene.new
- evo.pbStartScreen(pokemon,newspecies)
- evo.pbEvolution
- evo.pbEndScreen
- end
- end
- end
- end
- def pbDynamicItemList(*args)
- ret = []
- for i in 0...args.length
- if hasConst?(PBItems,args[i])
- ret.push(getConst(PBItems,args[i].to_sym))
- end
- end
- return ret
- end
- # Runs the Pickup event after a battle if a Pokemon has the ability Pickup.
- def Kernel.pbPickup(pokemon)
- return if !isConst?(pokemon.ability,PBAbilities,:PICKUP) || pokemon.egg?
- return if pokemon.item!=0
- return if rand(10)!=0
- pickupList = pbDynamicItemList(
- :POTION,
- :ANTIDOTE,
- :SUPERPOTION,
- :GREATBALL,
- :REPEL,
- :ESCAPEROPE,
- :FULLHEAL,
- :HYPERPOTION,
- :ULTRABALL,
- :REVIVE,
- :RARECANDY,
- :SUNSTONE,
- :MOONSTONE,
- :HEARTSCALE,
- :FULLRESTORE,
- :MAXREVIVE,
- :PPUP,
- :MAXELIXIR
- )
- pickupListRare = pbDynamicItemList(
- :HYPERPOTION,
- :NUGGET,
- :KINGSROCK,
- :FULLRESTORE,
- :ETHER,
- :IRONBALL,
- :DESTINYKNOT,
- :ELIXIR,
- :DESTINYKNOT,
- :LEFTOVERS,
- :DESTINYKNOT,
- :ICESTONE
- )
- return if pickupList.length<18
- return if pickupListRare.length<12
- randlist = [30,10,10,10,10,10,10,4,4,1,1]
- items = []
- plevel = [100,pokemon.level].min
- itemstart = (plevel-1)/10
- itemstart = 0 if itemstart<0
- for i in 0...9
- items.push(pickupList[itemstart+i])
- end
- for i in 0...2
- items.push(pickupListRare[itemstart+i])
- end
- rnd = rand(100)
- cumnumber = 0
- for i in 0...randlist.length
- cumnumber += randlist[i]
- if rnd<cumnumber
- pokemon.setItem(items[i])
- break
- end
- end
- end
- class PokeBattle_Scene
- 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
- for i in 0...8
- 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
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement