Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from operator import itemgetter
- import struct
- def portStats(rom, abilities, pokemon, csv) :
- types = ["Normal", "Fighting", "Flying", "Poison", \
- "Ground", "Rock", "Bug", "Ghost", "Steel", \
- "Fairy", "Fire", "Water", "Grass", "Electric", \
- "Psychic", "Ice", "Dragon", "Dark"]
- levelrates = ["Normal", "Erratic", "Fluctuating", \
- "Starter", "Fast", "Slow"]
- index = 1 #skip first line in this one
- stattable = 0x7228D4
- while index < len(csv) :
- line = csv[index].split(',')
- print(line[0])
- hp = int(line[7])
- patk = int(line[8])
- pdef = int(line[9])
- speed = int(line[12])
- satk = int(line[10])
- sdef = int(line[11])
- typea = types.index(line[1])
- typeb = types.index(line[2])
- catchrate = int(line[23])
- xpyield = int(line[22])
- print(line[22])
- ehp = int(line[15])
- eatk = int(line[16]) << 2
- edef = int(line[17]) << 4
- espeed = int(line[20]) << 6
- esatk = int(line[18]) << 8
- esdef = int(line[19]) << 10
- EVYield = ehp + eatk + edef + espeed + esatk + esdef
- itema = 0
- itemb = 0
- ssexrate = line[26]
- if ssexrate == "Neutral" :
- sexrate = 128
- elif ssexrate == "Male" :
- sexrate = 0
- elif ssexrate == "Female" :
- sexrate = 254
- elif ssexrate == "Neuter" :
- sexrate = 255
- elif ssexrate == "Masculine" :
- sexrate = 64
- elif ssexrate == "Feminine" :
- sexrate = 192
- eggrate = 10
- friendship = 70
- levelrate = levelrates.index(line[24])
- egggroup1 = 0
- egggroup2 = 0
- ability1 = abilities.index(line[4])
- ability2 = abilities.index(line[5])
- safarirate = 0
- colorflip = 0
- rom.seek(stattable + (0x1C * pokemon.index(line[0])), 0)
- rom.write(bytes([hp, patk, pdef, speed, satk, sdef, \
- typea, typeb, catchrate, xpyield]))
- rom.write(EVYield.to_bytes(2, 'little'))
- rom.write(itema.to_bytes(2, 'little'))
- rom.write(itemb.to_bytes(2, 'little'))
- rom.write(bytes([sexrate, eggrate, friendship, levelrate, \
- egggroup1, egggroup2, ability1, ability2,
- safarirate, colorflip, 0]))
- index += 1
- romname = "yafrh.gba"
- pokemon = []
- abilities = []
- csv = []
- with open("pokemon.txt", 'r') as f :
- s = f.read()
- badpokemon = s.split("\n")
- for p in badpokemon :
- pokemon += [p.strip()]
- with open("abilities.txt", 'r') as f :
- s = f.read()
- abilities = s.split("\n")
- with open("Yafrh Data - Base Stats.csv", 'r') as file :
- csv = file.read()
- csv = csv.split('\n')
- with open(romname, 'r+b') as file :
- portStats(file, abilities, pokemon, csv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement