Advertiser Content

Woah

Male
New Brunswick
Seen 1 Day Ago
Posted 3 Weeks Ago
120 posts
4.9 Years
How can I adjust this script so that the pokemon is able to learn the TM based on whether they can learn it through ANY means, be it by learning, move tutor, or the tm PBS file?

def pbSpeciesCompatible?(species,move)
  ret=false
  return false if species<=0
  data=load_data("Data/tm.dat")
  return false if !data[move]
  return data[move].any? {|item| item==species }
end
Compatibility is only determined by whether the TM is defined in tm.txt, and I'd like it to reference more than that. Any help is appreciated, thanks!

Vendily

Female
Seen 2 Hours Ago
Posted 4 Days Ago
888 posts
3.9 Years
Well, move tutor just looks at the TM list as well, unless you pass an optional list of Pokemon symbols to learn moves they otherwise couldn't.
Since we only get a species as an argument, we'd need to do basically the same loop that's done in def getMoveList on the Pokemon object.
def pbSpeciesCompatible?(species,move)
  ret=false
  return false if species<=0
  data=load_data("Data/tm.dat")
  return true if data[move] && data[move].any? {|item| item==species }
  movelist=[]
  atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
  offset=atkdata.getOffset(species-1)
  length=atkdata.getLength(species-1)>>1
  atkdata.pos=offset
  for k in 0..length-1
    level=atkdata.fgetw # just so the offset gets moved up.
    move=atkdata.fgetw
    movelist.push(move)
  end
  atkdata.close
  return movelist.include?(move)
end
I didn't test it though.

Woah

Male
New Brunswick
Seen 1 Day Ago
Posted 3 Weeks Ago
120 posts
4.9 Years
Well, move tutor just looks at the TM list as well, unless you pass an optional list of Pokemon symbols to learn moves they otherwise couldn't.
Since we only get a species as an argument, we'd need to do basically the same loop that's done in def getMoveList on the Pokemon object.
def pbSpeciesCompatible?(species,move)
  ret=false
  return false if species<=0
  data=load_data("Data/tm.dat")
  return true if data[move] && data[move].any? {|item| item==species }
  movelist=[]
  atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
  offset=atkdata.getOffset(species-1)
  length=atkdata.getLength(species-1)>>1
  atkdata.pos=offset
  for k in 0..length-1
    level=atkdata.fgetw # just so the offset gets moved up.
    move=atkdata.fgetw
    movelist.push(move)
  end
  atkdata.close
  return movelist.include?(move)
end
I didn't test it though.
Seems to work perfectly, thanks!

Edit: never mind, when I try to teach a pokemon one of the TMs, every possible pokemon is able to learn it, even though that's not true. Any thoughts?

Male
Seen 1 Week Ago
Posted 2 Weeks Ago
32 posts
171 Days
That's happening because the "move" parameter is getting re-assigned in the loop going through the species' move list, so the original parameter gets lost and is replaced with the last move in the move list by the end of the loop. You'll need to use a different variable name inside the loop, like so (change made in red):

def pbSpeciesCompatible?(species,move)
  ret=false
  return false if species<=0
  data=load_data("Data/tm.dat")
  return true if data[move] && data[move].any? {|item| item==species }
  movelist=[]
  atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
  offset=atkdata.getOffset(species-1)
  length=atkdata.getLength(species-1)>>1
  atkdata.pos=offset
  for k in 0..length-1
    level=atkdata.fgetw # just so the offset gets moved up.
    tempmove=atkdata.fgetw
    movelist.push(tempmove)
  end
  atkdata.close
  return movelist.include?(move)
end
Advertiser Content