#===============================================================================
# Technical Records - By Vendily [v17]
#===============================================================================
# This script adds in Technical Records, the replacement to consumable TMs
# that also have the ability to allow a mon to relearn the move at a
# Move Relearner if they forget it.
# Also adds in the system for Technical Records using the icon of the move type
# much like TMs.
#===============================================================================
# To use it, you must create a new item much like you would a TM or HM, but give
# it Item Usage 6 (if 6 is already used by some other script, you must edit
# pbIsTechnicalRecord? to use a different number)
#
# To use the type based icons, name the icon "itemRecordX", where X is either
# the internal name of the type, or the 3 digit padded type number.
# AKA. Either NORMAL or 000 will work for X
#
# You really should set INFINITETMS to true to get the most out of this script
# but it's not a requirement at all.
#===============================================================================
def pbIsMachine?(item)
return pbIsTechnicalMachine?(item) || pbIsHiddenMachine?(item) || pbIsTechnicalRecord?(item)
end
def pbIsTechnicalRecord?(item)
return $ItemData[item] && ($ItemData[item][ITEMUSE]==6)
end
#===============================================================================
# Use an item from the Bag and/or on a Pokémon
#===============================================================================
def pbUseItem(bag,item,bagscene=nil)
found=false
if pbIsMachine?(item) # TM or HM or TR
if $Trainer.pokemonCount==0
Kernel.pbMessage(_INTL("There is no Pokémon."))
return 0
end
machine=pbGetMachine(item)
return 0 if machine==nil
movename=PBMoves.getName(machine)
Kernel.pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",PBItems.getName(item)))
if !Kernel.pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",movename))
return 0
elsif mon=pbMoveTutorChoose(machine,nil,true)
bag.pbDeleteItem(item) if pbIsTechnicalMachine?(item) && !INFINITETMS
if pbIsTechnicalRecord?(item)
bag.pbDeleteItem(item)
$Trainer.party[mon].trmoves.push(machine)
end
return 1
else
return 0
end
elsif $ItemData[item][ITEMUSE]==1 || $ItemData[item][ITEMUSE]==5 # Item is usable on a Pokémon
if $Trainer.pokemonCount==0
Kernel.pbMessage(_INTL("There is no Pokémon."))
return 0
end
ret=false
annot=nil
if pbIsEvolutionStone?(item)
annot=[]
for pkmn in $Trainer.party
elig=(pbCheckEvolution(pkmn,item)>0)
annot.push(elig ? _INTL("ABLE") : _INTL("NOT ABLE"))
end
end
pbFadeOutIn(99999){
scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene,$Trainer.party)
screen.pbStartScene(_INTL("Use on which Pokémon?"),false,annot)
loop do
scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
chosen=screen.pbChoosePokemon
if chosen>=0
pokemon=$Trainer.party[chosen]
if pbCheckUseOnPokemon(item,pokemon,screen)
ret=ItemHandlers.triggerUseOnPokemon(item,pokemon,screen)
if ret && $ItemData[item][ITEMUSE]==1 # Usable on Pokémon, consumed
bag.pbDeleteItem(item)
end
if !bag.pbHasItem?(item)
Kernel.pbMessage(_INTL("You used your last {1}.",PBItems.getName(item)))
break
end
end
else
ret=false
break
end
end
screen.pbEndScene
bagscene.pbRefresh if bagscene
}
return ret ? 1 : 0
elsif $ItemData[item][ITEMUSE]==2 # Item is usable from bag
intret=ItemHandlers.triggerUseFromBag(item)
case intret
when 0; return 0
when 1; return 1 # Item used
when 2; return 2 # Item used, end screen
when 3; bag.pbDeleteItem(item); return 1 # Item used, consume item
when 4; bag.pbDeleteItem(item); return 2 # Item used, end screen and consume item
else; Kernel.pbMessage(_INTL("Can't use that here.")); return 0
end
else
Kernel.pbMessage(_INTL("Can't use that here."))
return 0
end
end
# Only called when in the party screen and having chosen an item to be used on
# the selected Pokémon
def pbUseItemOnPokemon(item,pokemon,scene)
if pbIsMachine?(item) # TM or HM or TR
machine=pbGetMachine(item)
return false if machine==nil
movename=PBMoves.getName(machine)
if (pokemon.isShadow? rescue false)
Kernel.pbMessage(_INTL("Shadow Pokémon can't be taught any moves."))
elsif !pokemon.isCompatibleWithMove?(machine)
Kernel.pbMessage(_INTL("{1} can't learn {2}.",pokemon.name,movename))
else
Kernel.pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",PBItems.getName(item)))
if Kernel.pbConfirmMessage(_INTL("Do you want to teach {1} to {2}?",movename,pokemon.name))
if pbLearnMove(pokemon,machine,false,true)
$PokemonBag.pbDeleteItem(item) if pbIsTechnicalMachine?(item) && !INFINITETMS
if pbIsTechnicalRecord?(item)
$PokemonBag.pbDeleteItem(item)
pokemon.trmoves.push(machine)
end
return true
end
end
end
return false
else
ret=ItemHandlers.triggerUseOnPokemon(item,pokemon,scene)
scene.pbClearAnnotations
scene.pbHardRefresh
if ret && $ItemData[item][ITEMUSE]==1 # Usable on Pokémon, consumed
$PokemonBag.pbDeleteItem(item)
end
if !$PokemonBag.pbHasItem?(item)
Kernel.pbMessage(_INTL("You used your last {1}.",PBItems.getName(item)))
end
return ret
end
Kernel.pbMessage(_INTL("Can't use that on {1}.",pokemon.name))
return false
end
def pbMoveTutorChoose(move,movelist=nil,bymachine=false)
ret = false
if move.is_a?(String) || move.is_a?(Symbol)
move = getID(PBMoves,move)
end
if movelist!=nil && movelist.is_a?(Array)
for i in 0...movelist.length
if movelist[i].is_a?(String) || movelist[i].is_a?(Symbol)
movelist[i] = getID(PBSpecies,movelist[i])
end
end
end
pbFadeOutIn(99999){
movename = PBMoves.getName(move)
annot = pbMoveTutorAnnotations(move,movelist)
scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene,$Trainer.party)
screen.pbStartScene(_INTL("Teach which Pokémon?"),false,annot)
loop do
chosen = screen.pbChoosePokemon
if chosen>=0
pokemon = $Trainer.party[chosen]
if pokemon.egg?
Kernel.pbMessage(_INTL("Eggs can't be taught any moves."))
elsif (pokemon.isShadow? rescue false)
Kernel.pbMessage(_INTL("Shadow Pokémon can't be taught any moves."))
elsif movelist && !movelist.any?{|j| j==pokemon.species }
Kernel.pbMessage(_INTL("{1} can't learn {2}.",pokemon.name,movename))
elsif !pokemon.isCompatibleWithMove?(move)
Kernel.pbMessage(_INTL("{1} can't learn {2}.",pokemon.name,movename))
else
if pbLearnMove(pokemon,move,false,bymachine)
ret = chosen
break
end
end
else
break
end
end
screen.pbEndScene
}
return ret # Returns whether the move was learned by a Pokemon
end
#===============================================================================
# Load item icons
#===============================================================================
def pbItemIconFile(item)
return nil if !item
bitmapFileName = nil
if item==0
bitmapFileName = sprintf("Graphics/Icons/itemBack")
else
bitmapFileName = sprintf("Graphics/Icons/item%s",getConstantName(PBItems,item)) rescue nil
if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Icons/item%03d",item)
if !pbResolveBitmap(bitmapFileName) && pbIsTechnicalRecord?(item)
move = pbGetMachine(item)
type = PBMoveData.new(move).type
bitmapFileName = sprintf("Graphics/Icons/itemRecord%s",getConstantName(PBTypes,type)) rescue nil
if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Icons/itemRecord%03d",type)
end
end
if !pbResolveBitmap(bitmapFileName) && pbIsMachine?(item)
move = pbGetMachine(item)
type = PBMoveData.new(move).type
bitmapFileName = sprintf("Graphics/Icons/itemMachine%s",getConstantName(PBTypes,type)) rescue nil
if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Icons/itemMachine%03d",type)
end
end
end
end
return bitmapFileName
end
class PokeBattle_Pokemon
attr_accessor :trmoves
def trmoves
@trmoves=[] if !@trmoves
return @trmoves
end
end
alias tr_pbGetRelearnableMoves pbGetRelearnableMoves
def pbGetRelearnableMoves(pokemon)
ret=tr_pbGetRelearnableMoves(pokemon)
trmoves=[]
for i in pokemon.trmoves
trmoves.push(i) if !pokemon.hasMove?(i) && !ret.include?(i)
end
ret=ret+trmoves
return ret|[]
end