- 3
- Posts
- 16
- Years
- Seen Apr 27, 2019
Hello,
I've been playing with the move relearner a bit lately. I successfully turned it into a key item, no heartscale needed.
But now, I though it would be even better to add a "Relearn moves" option when you select a Pokemon on the party screen. I got the idea from the debug menu which allows players to teach a pokemon any move, much faster than through the "move relearner" screen.
I somehow made it to add a "Relearn" option when selecting a Pokemon in party screen. And I "created" the script, VASTLY inspired from bits of the "PScreen_MoveRelearner" and "Editor_Utilities" scripts : I rename and use the commands "pbHasRelearnableMove?(pokemon)" and "pbChooseMoveListForSpecies(pokemon,defaultMoveID=0)" ...
After some fiddling, it doesn't crash but ... It gives me the list of ALL moves, instead of just the moves the selected Pokemon can learn. And I tried, it lets me teach my Pokemon moves it shouldn't be able to learn.
Note that all my Pokemon only have level up moves, but no eggmove or TM/HM move.
Here is what the code looks like :
And the part in "PScreen_Party" calling this code (taken from the "Debug_Pokemon" script, "teachmove" part) :
Does anyone knows why it gives me the full list of moves instead of just the moves the Pokemon can actually learn?
Thanks in advance! And don't hesitate to ask if you need more details.
I've been playing with the move relearner a bit lately. I successfully turned it into a key item, no heartscale needed.
But now, I though it would be even better to add a "Relearn moves" option when you select a Pokemon on the party screen. I got the idea from the debug menu which allows players to teach a pokemon any move, much faster than through the "move relearner" screen.
I somehow made it to add a "Relearn" option when selecting a Pokemon in party screen. And I "created" the script, VASTLY inspired from bits of the "PScreen_MoveRelearner" and "Editor_Utilities" scripts : I rename and use the commands "pbHasRelearnableMove?(pokemon)" and "pbChooseMoveListForSpecies(pokemon,defaultMoveID=0)" ...
After some fiddling, it doesn't crash but ... It gives me the list of ALL moves, instead of just the moves the selected Pokemon can learn. And I tried, it lets me teach my Pokemon moves it shouldn't be able to learn.
Note that all my Pokemon only have level up moves, but no eggmove or TM/HM move.
Here is what the code looks like :
Code:
def pbLabEachNaturalMove(pokemon)
movelist=pokemon.getMoveList
for i in movelist
yield i[1],i[0]
end
end
def pbLabHasRelearnableMove?(pokemon)
return pbLabGetRelearnableMoves(pokemon).length>0
end
def pbLabGetRelearnableMoves(pokemon)
return [] if !pokemon || # pokemon.egg? || (pokemon.isShadow? rescue false)
moves=[]
pbLabEachNaturalMove(pokemon){|move,level|
if level<=pokemon.level && !pokemon.hasMove?(move)
moves.push(move) if !moves.include?(move)
end
}
tmoves=[]
if pokemon.firstmoves
for i in pokemon.firstmoves
tmoves.push(i) if !pokemon.hasMove?(i) && !moves.include?(i)
end
end
moves=tmoves+moves
return moves|[] # remove duplicates
end
def pbLabChooseMoveListForSpecies(pokemon,defaultMoveID=0)
cmdwin = pbListWindow([],200)
commands = []
moveDefault = 0
legalMoves = pbLabGetRelearnableMoves(pokemon)
for move in legalMoves
commands.push([move,PBMoves.getName(move)])
end
commands.sort! {|a,b| a[1]<=>b[1] }
if defaultMoveID>0
commands.each_with_index{|item,index|
if moveDefault==0
moveDefault = index if index[0]==defaultMoveID
end
}
end
commands2 = []
for i in 1..PBMoves.maxValue
if PBMoves.getName(i)!=nil && PBMoves.getName(i)!=""
commands2.push([i,PBMoves.getName(i)])
end
end
commands2.sort!{|a,b| a[1]<=>b[1] }
if defaultMoveID>0
commands2.each_with_index{|item,index|
if moveDefault==0
moveDefault = index if index[0]==defaultMoveID
end
}
end
commands.concat(commands2)
realcommands = []
for command in commands
realcommands.push("#{command[1]}")
end
ret = pbCommands2(cmdwin,realcommands,-1,moveDefault,true)
cmdwin.dispose
return (ret>=0) ? commands[ret][0] : 0
end
And the part in "PScreen_Party" calling this code (taken from the "Debug_Pokemon" script, "teachmove" part) :
Code:
elsif cmdRelearn>=0 && command==cmdRelearn
move = pbLabChooseMoveListForSpecies(pkmn.species)
if move!=0
pbLearnMove(pkmn,move)
pbRefreshSingle(pkmnid)
end
Does anyone knows why it gives me the full list of moves instead of just the moves the Pokemon can actually learn?
Thanks in advance! And don't hesitate to ask if you need more details.