require 'optparse' load 'poke.list' # # patch a pokemon diamond rom to change the special pokemons that appear in the mansion # # offset found using proximity_scanner with some mansion-specific pokemon id # list is a sequence of 16 dwords near the end of the file, seems close to honey-tree/great march list # # usage: args = 16 pokemon names, if any is invalid the rom is not modified # shows the previous list # file = 'poke-diamond.nds' offset = 0x368e154 OptionParser.new {|opt| opt.on('-f file') { |f| file = f } opt.on('-o off') { |o| offset = Integer(o) } }.parse!(ARGV) mylist = ARGV.map { |a| Pokelist.find { |k, v| v.downcase == a.downcase }.to_a[0] } File.open(file, 'r+') { |fd| fd.pos = offset puts 'had' puts fd.read(16*4).unpack('L*').map { |i| Pokelist[i] } fd.pos = offset if mylist.compact.length != 16 mylist[15] ||= nil puts "bad arglist #{mylist.inspect}" else fd.write mylist.pack('L*') end }