def pbPokemonScreen
@scene.pbStartScene(@party,@party.length>1 ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),nil)
loop do
@scene.pbSetHelpText(@party.length>1 ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
[email protected]
break if pkmnid<0
pkmn=@party[pkmnid]
commands=[]
cmdSummary=-1
cmdDebug=-1
cmdMoves=[-1,-1,-1,-1]
cmdSwitch=-1
cmdMail=-1
cmdItem=-1
cmdRelease=-1
# Build the commands
commands[cmdSummary=commands.length]=_INTL("Summary")
commands[cmdDebug=commands.length]=_INTL("Debug") if $DEBUG
for i in 0...pkmn.moves.length
move=pkmn.moves[i]
# Check for hidden moves and add any that were found
if !pkmn.isEgg? && (isConst?(move.id,PBMoves,:MILKDRINK) ||
isConst?(move.id,PBMoves,:SOFTBOILED) ||
HiddenMoveHandlers.hasHandler(move.id))
commands[cmdMoves[i]=commands.length]=PBMoves.getName(move.id)
end
end
commands[cmdSwitch=commands.length]=_INTL("Switch") if @party.length>1
if !pkmn.isEgg?
if pkmn.mail
commands[cmdMail=commands.length]=_INTL("Mail")
else
commands[cmdItem=commands.length]=_INTL("Item")
end
end
commands[cmdRelease=commands.length]=_INTL("Release")
commands[commands.length]=_INTL("Cancel")
[email protected](_INTL("Do what with {1}?",pkmn.name),commands)
havecommand=false
for i in 0...4
if cmdMoves[i]>=0 && command==cmdMoves[i]
havecommand=true
if isConst?(pkmn.moves[i].id,PBMoves,:SOFTBOILED) ||
isConst?(pkmn.moves[i].id,PBMoves,:MILKDRINK)
if pkmn.hp<=(pkmn.totalhp/5).floor
pbDisplay(_INTL("Not enough HP..."))
break
end
@scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
oldpkmnid=pkmnid
loop do
@scene.pbPreSelect(oldpkmnid)
[email protected](true,pkmnid)
break if pkmnid<0
newpkmn=@party[pkmnid]
if pkmnid==oldpkmnid
pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,PBMoves.getName(pkmn.moves[i].id)))
elsif newpkmn.isEgg?
pbDisplay(_INTL("{1} can't be used on an Egg!",PBMoves.getName(pkmn.moves[i].id)))
elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp
pbDisplay(_INTL("{1} can't be used on that Pokémon.",PBMoves.getName(pkmn.moves[i].id)))
else
pkmn.hp-=(pkmn.totalhp/5).floor
hpgain=pbItemRestoreHP(newpkmn,(pkmn.totalhp/5).floor)
@scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
pbRefresh
end
break if pkmn.hp<=(pkmn.totalhp/5).floor
end
break
elsif Kernel.pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id)
@scene.pbEndScene
if isConst?(pkmn.moves[i].id,PBMoves,:FLY)
scene=PokemonRegionMapScene.new(-1,false)
screen=PokemonRegionMap.new(scene)
ret=screen.pbStartFlyScreen
if ret
$PokemonTemp.flydata=ret
return [pkmn,pkmn.moves[i].id]
end
@scene.pbStartScene(@party,
@party.length>1 ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
break
end
return [pkmn,pkmn.moves[i].id]
else
break
end
end
end
next if havecommand
if cmdSummary>=0 && command==cmdSummary
@scene.pbSummary(pkmnid)
elsif cmdDebug>=0 && command==cmdDebug
pbPokemonDebug(pkmn,pkmnid)
elsif cmdSwitch>=0 && command==cmdSwitch
@scene.pbSetHelpText(_INTL("Move to where?"))
oldpkmnid=pkmnid
[email protected](true)
if pkmnid>=0 && pkmnid!=oldpkmnid
pbSwitch(oldpkmnid,pkmnid)
end
elsif cmdMail>=0 && command==cmdMail
[email protected](_INTL("Do what with the mail?"),
[_INTL("Read"),_INTL("Take"),_INTL("Cancel")])
case command
when 0 # Read
pbFadeOutIn(99999){
pbDisplayMail(pkmn.mail,pkmn)
}
when 1 # Take
pbTakeMail(pkmn)
pbRefreshSingle(pkmnid)
end
elsif cmdItem>=0 && command==cmdItem
itemcommands=[]
cmdUseItem=-1
cmdGiveItem=-1
cmdTakeItem=-1
cmdMoveItem=-1
# Build the commands
itemcommands[cmdUseItem=itemcommands.length]=_INTL("Use")
itemcommands[cmdGiveItem=itemcommands.length]=_INTL("Give")
itemcommands[cmdTakeItem=itemcommands.length]=_INTL("Take") if pkmn.hasItem?
itemcommands[cmdMoveItem=itemcommands.length]=_INTL("Move") if pkmn.hasItem? && !pbIsMail?(pkmn.item)
itemcommands[itemcommands.length]=_INTL("Cancel")
[email protected](_INTL("Do what with an item?"),itemcommands)
if cmdUseItem>=0 && command==cmdUseItem # Use
[email protected]($PokemonBag,pkmn)
if item>0
pbUseItemOnPokemon(item,pkmn,self)
pbRefreshSingle(pkmnid)
end
elsif cmdGiveItem>=0 && command==cmdGiveItem # Give
[email protected]($PokemonBag)
if item>0
pbGiveMail(item,pkmn,pkmnid)
pbRefreshSingle(pkmnid)
end
elsif cmdTakeItem>=0 && command==cmdTakeItem # Take
pbTakeMail(pkmn)
pbRefreshSingle(pkmnid)
elsif cmdMoveItem>=0 && command==cmdMoveItem # Move
item=pkmn.item
itemname=PBItems.getName(item)
@scene.pbSetHelpText(_INTL("Give {1} to which Pokémon?",itemname))
oldpkmnid=pkmnid
loop do
@scene.pbPreSelect(oldpkmnid)
[email protected](true,pkmnid)
break if pkmnid<0
newpkmn=@party[pkmnid]
if pkmnid==oldpkmnid
break
elsif newpkmn.isEgg?
pbDisplay(_INTL("Eggs can't hold items."))
elsif !newpkmn.hasItem?
newpkmn.setItem(item)
pkmn.setItem(0)
pbRefresh
pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
break
elsif pbIsMail?(newpkmn.item)
pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",newpkmn.name))
else
newitem=newpkmn.item
newitemname=PBItems.getName(newitem)
pbDisplay(_INTL("{1} is already holding one {2}.\1",newpkmn.name,newitemname))
if pbConfirm(_INTL("Would you like to switch the two items?"))
newpkmn.setItem(item)
pkmn.setItem(newitem)
pbRefresh
pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
pbDisplay(_INTL("{1} was given the {2} to hold.",pkmn.name,newitemname))
break
end
end
end
end
elsif cmdRelease>=0 && command==cmdRelease
prty_len =0
for i in 0...$Trainer.party.length
prty_len+=1 if !$Trainer.party[i].isEgg?
end
if pkmn.isEgg?
pbDisplay(_INTL("You can't release an Egg."))
elsif pkmn.mail
pbDisplay(_INTL("Please remove the mail."))
elsif prty_len<=1
pbDisplay(_INTL("You can't release your last Pokemon!"))
else
if pbConfirm(_INTL("Are you sure you want to release {1}",pkmn.name))
@party[pkmnid]=nil
@party.compact!
pbHardRefresh
pbDisplay(_INTL("{1} was released. Bye-bye!",pkmn.name))
end
end
end
end
@scene.pbEndScene
return nil
end