Advertisement
Doesnt

statsporter.py

May 12th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. from operator import itemgetter
  2. import struct
  3.  
  4. def portStats(rom, abilities, pokemon, csv) :
  5. types = ["Normal", "Fighting", "Flying", "Poison", \
  6. "Ground", "Rock", "Bug", "Ghost", "Steel", \
  7. "Fairy", "Fire", "Water", "Grass", "Electric", \
  8. "Psychic", "Ice", "Dragon", "Dark"]
  9. levelrates = ["Normal", "Erratic", "Fluctuating", \
  10. "Starter", "Fast", "Slow"]
  11. index = 1 #skip first line in this one
  12. stattable = 0x7228D4
  13. while index < len(csv) :
  14. line = csv[index].split(',')
  15. print(line[0])
  16.  
  17. hp = int(line[7])
  18. patk = int(line[8])
  19. pdef = int(line[9])
  20. speed = int(line[12])
  21. satk = int(line[10])
  22. sdef = int(line[11])
  23. typea = types.index(line[1])
  24. typeb = types.index(line[2])
  25. catchrate = int(line[23])
  26. xpyield = int(line[22])
  27. print(line[22])
  28.  
  29. ehp = int(line[15])
  30. eatk = int(line[16]) << 2
  31. edef = int(line[17]) << 4
  32. espeed = int(line[20]) << 6
  33. esatk = int(line[18]) << 8
  34. esdef = int(line[19]) << 10
  35. EVYield = ehp + eatk + edef + espeed + esatk + esdef
  36.  
  37. itema = 0
  38. itemb = 0
  39. ssexrate = line[26]
  40. if ssexrate == "Neutral" :
  41. sexrate = 128
  42. elif ssexrate == "Male" :
  43. sexrate = 0
  44. elif ssexrate == "Female" :
  45. sexrate = 254
  46. elif ssexrate == "Neuter" :
  47. sexrate = 255
  48. elif ssexrate == "Masculine" :
  49. sexrate = 64
  50. elif ssexrate == "Feminine" :
  51. sexrate = 192
  52.  
  53.  
  54. eggrate = 10
  55. friendship = 70
  56. levelrate = levelrates.index(line[24])
  57. egggroup1 = 0
  58. egggroup2 = 0
  59. ability1 = abilities.index(line[4])
  60. ability2 = abilities.index(line[5])
  61. safarirate = 0
  62. colorflip = 0
  63.  
  64. rom.seek(stattable + (0x1C * pokemon.index(line[0])), 0)
  65. rom.write(bytes([hp, patk, pdef, speed, satk, sdef, \
  66. typea, typeb, catchrate, xpyield]))
  67. rom.write(EVYield.to_bytes(2, 'little'))
  68. rom.write(itema.to_bytes(2, 'little'))
  69. rom.write(itemb.to_bytes(2, 'little'))
  70. rom.write(bytes([sexrate, eggrate, friendship, levelrate, \
  71. egggroup1, egggroup2, ability1, ability2,
  72. safarirate, colorflip, 0]))
  73. index += 1
  74.  
  75.  
  76. romname = "yafrh.gba"
  77.  
  78. pokemon = []
  79. abilities = []
  80. csv = []
  81.  
  82. with open("pokemon.txt", 'r') as f :
  83. s = f.read()
  84.  
  85. badpokemon = s.split("\n")
  86. for p in badpokemon :
  87. pokemon += [p.strip()]
  88.  
  89.  
  90. with open("abilities.txt", 'r') as f :
  91. s = f.read()
  92. abilities = s.split("\n")
  93.  
  94.  
  95.  
  96. with open("Yafrh Data - Base Stats.csv", 'r') as file :
  97. csv = file.read()
  98. csv = csv.split('\n')
  99. with open(romname, 'r+b') as file :
  100. portStats(file, abilities, pokemon, csv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement