Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from operator import itemgetter
- import struct
- def loadMovepools(csv, movepools) :
- emptymons = ["","","","","",""]
- mons = ["","","","","",""]
- for line in csv :
- text = line.split(',')
- if mons == emptymons :
- print(line)
- mons[0] = text[1]
- mons[1] = text[2]
- mons[2] = text[3]
- mons[3] = text[4]
- mons[4] = text[5]
- mons[5] = text[6]
- movepools[mons[0]] = []
- movepools[mons[1]] = []
- movepools[mons[2]] = []
- movepools[mons[3]] = []
- movepools[mons[4]] = []
- movepools[mons[5]] = []
- elif text[0] == "Evolution" :
- continue
- elif text[0] == "" :
- mons = ["","","","","",""]
- else :
- move = text[0]
- for i in range(0,6) :
- if mons[i] != '' and text[i+1] != '':
- movepools[mons[i]] += (text[i+1], text[0])
- def insertMovepools(rom, pokemon, moves, movepools) :
- freespace = 0xC80000
- movepooltable = 0x25D7B4
- for i in range(0, len(pokemon)) :
- if not (pokemon[i] in movepools) :
- continue
- else :
- print(pokemon[i])
- index = 0
- offset = freespace
- rom.seek(movepooltable + (4 * i))
- rom.write((0x8000000 + freespace).to_bytes(4, 'little'))
- while index < len(movepools[pokemon[i]]) :
- level = movepools[pokemon[i]][index]
- move = movepools[pokemon[i]][index+1]
- moveno = moves.index(move)
- data = (int(level) << 9) + moveno
- rom.seek(freespace)
- rom.write(data.to_bytes(2, 'little'))
- print(data)
- freespace += 2
- index += 2
- rom.write((0xFFFF).to_bytes(2, 'little'))
- freespace += 2
- rom.seek(freespace)
- rom.write((0x7777).to_bytes(2, 'little'))
- romname = "badnik.gba"
- pokemon = []
- moves = []
- csv = []
- movepools = dict()
- with open("pokemon.txt", 'r') as f :
- s = f.read()
- badpokemon = s.split("\n")
- for p in badpokemon :
- pokemon += [p.strip()]
- with open("moves.txt", 'r') as f :
- s = f.read()
- moves = s.split("\n")
- with open("badnik template - Sheet1.csv", 'r') as file :
- csv = file.read()
- csv = csv.split('\n')
- loadMovepools(csv, movepools)
- print(movepools)
- with open(romname, 'r+b') as file :
- insertMovepools(file, pokemon, moves, movepools)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement