mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Adds menu option for Pokemon to remember any previously learned moves
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -445,6 +445,7 @@ def pbLearnMove(pkmn, move, ignoreifknown = false, bymachine = false, fast = fal
|
|||||||
end
|
end
|
||||||
pkmnname = pkmn.name
|
pkmnname = pkmn.name
|
||||||
movename = GameData::Move.get(move).name
|
movename = GameData::Move.get(move).name
|
||||||
|
pkmn.add_learned_move(move) if !bymachine
|
||||||
if pkmn.hasMove?(move)
|
if pkmn.hasMove?(move)
|
||||||
pbMessage(_INTL("{1} already knows {2}.", pkmnname, movename), &block) if !ignoreifknown
|
pbMessage(_INTL("{1} already knows {2}.", pkmnname, movename), &block) if !ignoreifknown
|
||||||
return false
|
return false
|
||||||
@@ -462,7 +463,12 @@ def pbLearnMove(pkmn, move, ignoreifknown = false, bymachine = false, fast = fal
|
|||||||
if forgetmove >= 0
|
if forgetmove >= 0
|
||||||
oldmovename = pkmn.moves[forgetmove].name
|
oldmovename = pkmn.moves[forgetmove].name
|
||||||
oldmovepp = pkmn.moves[forgetmove].pp
|
oldmovepp = pkmn.moves[forgetmove].pp
|
||||||
|
forgotten_move = pkmn.moves[forgetmove]
|
||||||
|
pkmn.add_learned_move(forgotten_move)
|
||||||
|
|
||||||
pkmn.moves[forgetmove] = Pokemon::Move.new(move) # Replaces current/total PP
|
pkmn.moves[forgetmove] = Pokemon::Move.new(move) # Replaces current/total PP
|
||||||
|
pkmn.add_learned_move(move)
|
||||||
|
|
||||||
if bymachine && Settings::TAUGHT_MACHINES_KEEP_OLD_PP
|
if bymachine && Settings::TAUGHT_MACHINES_KEEP_OLD_PP
|
||||||
pkmn.moves[forgetmove].pp = [oldmovepp, pkmn.moves[forgetmove].total_pp].min
|
pkmn.moves[forgetmove].pp = [oldmovepp, pkmn.moves[forgetmove].total_pp].min
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class Pokemon
|
|||||||
# @return [Array<Pokemon::Move>] the moves known by this Pokémon
|
# @return [Array<Pokemon::Move>] the moves known by this Pokémon
|
||||||
attr_accessor :moves
|
attr_accessor :moves
|
||||||
|
|
||||||
# @return [Array<Pokemon::Move>] All the moves ever learned by this Pokémon
|
# @return [Array<Symbol>] All the move (ids) ever learned by this Pokémon
|
||||||
attr_accessor :learned_moves
|
attr_accessor :learned_moves
|
||||||
|
|
||||||
# @return [Array<Integer>] the IDs of moves known by this Pokémon when it was obtained
|
# @return [Array<Integer>] the IDs of moves known by this Pokémon when it was obtained
|
||||||
@@ -874,14 +874,20 @@ class Pokemon
|
|||||||
for i in first_move_index...knowable_moves.length
|
for i in first_move_index...knowable_moves.length
|
||||||
move = Pokemon::Move.new(knowable_moves[i])
|
move = Pokemon::Move.new(knowable_moves[i])
|
||||||
@moves.push(move)
|
@moves.push(move)
|
||||||
@learned_moves = [] if !@learned_moves
|
add_learned_move(move)
|
||||||
@learned_moves << move if !@learned_moves.include?(move)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_learned_move(move)
|
def add_learned_move(move)
|
||||||
@learned_moves = [] if !@learned_moves
|
@learned_moves = [] if !@learned_moves
|
||||||
@learned_moves << move unless @learned_moves.include?(move)
|
if move.is_a?(Symbol)
|
||||||
|
@learned_moves << move unless @learned_moves.include?(move)
|
||||||
|
else
|
||||||
|
move_id = move.id
|
||||||
|
if move_id
|
||||||
|
@learned_moves << move_id unless @learned_moves.include?(move_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -902,9 +908,7 @@ class Pokemon
|
|||||||
@moves.push(move)
|
@moves.push(move)
|
||||||
# Delete the first known move if self now knows more moves than it should
|
# Delete the first known move if self now knows more moves than it should
|
||||||
@moves.shift if numMoves > MAX_MOVES
|
@moves.shift if numMoves > MAX_MOVES
|
||||||
@learned_moves = [] if !@learned_moves
|
add_learned_move(move)
|
||||||
@learned_moves << move if !@learned_moves.include?(move)
|
|
||||||
echoln @learned_moves
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes the given move from the Pokémon.
|
# Deletes the given move from the Pokémon.
|
||||||
@@ -912,17 +916,23 @@ class Pokemon
|
|||||||
def forget_move(move_id)
|
def forget_move(move_id)
|
||||||
move_data = GameData::Move.try_get(move_id)
|
move_data = GameData::Move.try_get(move_id)
|
||||||
return if !move_data
|
return if !move_data
|
||||||
|
add_learned_move(move_id)
|
||||||
@moves.delete_if { |m| m.id == move_data.id }
|
@moves.delete_if { |m| m.id == move_data.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes the move at the given index from the Pokémon.
|
# Deletes the move at the given index from the Pokémon.
|
||||||
# @param index [Integer] index of the move to be deleted
|
# @param index [Integer] index of the move to be deleted
|
||||||
def forget_move_at_index(index)
|
def forget_move_at_index(index)
|
||||||
|
move_id = @moves[index].id
|
||||||
|
add_learned_move(move_id)
|
||||||
@moves.delete_at(index)
|
@moves.delete_at(index)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes all moves from the Pokémon.
|
# Deletes all moves from the Pokémon.
|
||||||
def forget_all_moves
|
def forget_all_moves
|
||||||
|
for move in @moves
|
||||||
|
add_learned_move(move)
|
||||||
|
end
|
||||||
@moves.clear
|
@moves.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1190,6 +1190,43 @@ class PokemonPartyScreen
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pbRememberMoves(pokemon)
|
||||||
|
learnable_moves = pokemon.learned_moves
|
||||||
|
learnable_moves = [] if !learnable_moves
|
||||||
|
#exclude current moves
|
||||||
|
echoln "learned moves: #{learnable_moves}"
|
||||||
|
for current_move in pokemon.moves
|
||||||
|
echoln current_move.id
|
||||||
|
if learnable_moves.include?(current_move.id)
|
||||||
|
learnable_moves.delete(current_move.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
move_ids = []
|
||||||
|
for move in learnable_moves
|
||||||
|
if move.is_a?(Symbol)
|
||||||
|
move_ids << move
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if move_ids.empty?
|
||||||
|
pbMessage(_INTL("{1} has no moves to remember!",pokemon.name))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
echoln move_ids
|
||||||
|
|
||||||
|
retval = true
|
||||||
|
pbFadeOutIn {
|
||||||
|
scene = MoveRelearner_Scene.new
|
||||||
|
screen = MoveRelearnerScreen.new(scene)
|
||||||
|
if !learnable_moves.empty?
|
||||||
|
retval = screen.pbStartScreen(pokemon, move_ids)
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
}
|
||||||
|
return retval
|
||||||
|
end
|
||||||
def pbPokemonRename(pkmn, pkmnid)
|
def pbPokemonRename(pkmn, pkmnid)
|
||||||
cmd = 0
|
cmd = 0
|
||||||
loop do
|
loop do
|
||||||
@@ -1240,6 +1277,7 @@ class PokemonPartyScreen
|
|||||||
cmdMail = -1
|
cmdMail = -1
|
||||||
cmdItem = -1
|
cmdItem = -1
|
||||||
cmdHat = -1
|
cmdHat = -1
|
||||||
|
cmdLearnMove = -1
|
||||||
|
|
||||||
# Build the commands
|
# Build the commands
|
||||||
commands[cmdSummary = commands.length] = _INTL("Summary")
|
commands[cmdSummary = commands.length] = _INTL("Summary")
|
||||||
@@ -1263,6 +1301,8 @@ class PokemonPartyScreen
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
commands[cmdNickname = commands.length] = _INTL("Nickname") if !pkmn.egg?
|
commands[cmdNickname = commands.length] = _INTL("Nickname") if !pkmn.egg?
|
||||||
|
commands[cmdLearnMove = commands.length] = _INTL("Remember moves")
|
||||||
|
|
||||||
commands[commands.length] = _INTL("Cancel")
|
commands[commands.length] = _INTL("Cancel")
|
||||||
command = @scene.pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands)
|
command = @scene.pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands)
|
||||||
havecommand = false
|
havecommand = false
|
||||||
@@ -1324,6 +1364,8 @@ class PokemonPartyScreen
|
|||||||
}
|
}
|
||||||
elsif cmdHat >= 0 && command == cmdHat
|
elsif cmdHat >= 0 && command == cmdHat
|
||||||
pbPokemonHat(pkmn)
|
pbPokemonHat(pkmn)
|
||||||
|
elsif cmdLearnMove > 0 && command == cmdLearnMove
|
||||||
|
pbRememberMoves(pkmn)
|
||||||
elsif cmdNickname >= 0 && command == cmdNickname
|
elsif cmdNickname >= 0 && command == cmdNickname
|
||||||
pbPokemonRename(pkmn, pkmnid)
|
pbPokemonRename(pkmn, pkmnid)
|
||||||
elsif cmdDebug >= 0 && command == cmdDebug
|
elsif cmdDebug >= 0 && command == cmdDebug
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ class MoveRelearnerScreen
|
|||||||
end
|
end
|
||||||
if move
|
if move
|
||||||
if @scene.pbConfirm(_INTL("Teach {1}?", GameData::Move.get(move).name))
|
if @scene.pbConfirm(_INTL("Teach {1}?", GameData::Move.get(move).name))
|
||||||
if pbLearnMove(pkmn, move)
|
if pbLearnMove(pkmn, move, false, true)
|
||||||
@scene.pbEndScene
|
@scene.pbEndScene
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user