def pbGiveItemToPokemon(item,pokemon,scene,pkmnid=0)
newitemname = PBItems.getName(item)
if pokemon.egg?
scene.pbDisplay(_INTL("Eggs can't hold items."))
return false
elsif pokemon.mail
scene.pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",pokemon.name))
return false if !pbTakeItemFromPokemon(pokemon,scene)
end
if pokemon.hasItem?
olditemname = PBItems.getName(pokemon.item)
if isConst?(pokemon.item,PBItems,:LEFTOVERS)
scene.pbDisplay(_INTL("{1} is already holding some {2}.\1",pokemon.name,olditemname))
elsif ['a','e','i','o','u'].include?(newitemname[0,1].downcase)
scene.pbDisplay(_INTL("{1} is already holding an {2}.\1",pokemon.name,olditemname))
else
scene.pbDisplay(_INTL("{1} is already holding a {2}.\1",pokemon.name,olditemname))
end
if scene.pbConfirm(_INTL("Would you like to switch the two items?"))
$PokemonBag.pbDeleteItem(item)
if !$PokemonBag.pbStoreItem(pokemon.item)
if !$PokemonBag.pbStoreItem(item)
raise _INTL("Could't re-store deleted item in Bag somehow")
end
scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed."))
else
if pbIsMail?(item)
if pbWriteMail(item,pokemon,pkmnid,scene)
pokemon.setItem(item)
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.",olditemname,pokemon.name,newitemname))
return true
else
if !$PokemonBag.pbStoreItem(item)
raise _INTL("Couldn't re-store deleted item in Bag somehow")
end
end
else
pokemon.setItem(item)
if isConst?(item,PBItems,:MAMMAMIA) && isConst?(pokemon.species,PBSpecies,:MIMI) && pokemon.form>0 && pokemon.form<3
pokemon.mimimi=pokemon.form
pokemon.form=3
end
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.",olditemname,pokemon.name,newitemname))
return true
end
end
end
else
if !pbIsMail?(item) || pbWriteMail(item,pokemon,pkmnid,scene)
$PokemonBag.pbDeleteItem(item)
pokemon.setItem(item)
if isConst?(item,PBItems,:MAMMAMIA) && isConst?(pokemon.species,PBSpecies,:MIMI) && pokemon.form!=0
pokemon.mimimi=pokemon.form
pokemon.form=3
end
scene.pbDisplay(_INTL("{1} is now holding the {2}.",pokemon.name,newitemname))
return true
end
end
return false
end
def pbTakeItemFromPokemon(pokemon,scene)
ret = false
if !pokemon.hasItem?
scene.pbDisplay(_INTL("{1} isn't holding anything.",pokemon.name))
elsif !$PokemonBag.pbCanStore?(pokemon.item)
scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed."))
elsif pokemon.mail
if scene.pbConfirm(_INTL("Save the removed mail in your PC?"))
if !pbMoveToMailbox(pokemon)
scene.pbDisplay(_INTL("Your PC's Mailbox is full."))
else
scene.pbDisplay(_INTL("The mail was saved in your PC."))
pokemon.setItem(0)
ret = true
end
elsif scene.pbConfirm(_INTL("If the mail is removed, its message will be lost. OK?"))
$PokemonBag.pbStoreItem(pokemon.item)
itemname = PBItems.getName(pokemon.item)
scene.pbDisplay(_INTL("Received the {1} from {2}.",itemname,pokemon.name))
pokemon.setItem(0)
pokemon.mail = nil
ret = true
end
else
$PokemonBag.pbStoreItem(pokemon.item)
itemname = PBItems.getName(pokemon.item)
scene.pbDisplay(_INTL("Received the {1} from {2}.",itemname,pokemon.name))
if isConst?(pokemon.item,PBItems,:MAMMAMIA) && isConst?(pokemon.species,PBSpecies,:MIMI) && pokemon.form==3
pokemon.form=pokemon.mimimi
pokemon.setItem(0)
else
pokemon.setItem(0)
end
ret = true
end
return ret
end