kd2bwzgen

ffs

Apr 4th, 2018
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import itertools
  2.  
  3. flatten = lambda x: list(itertools.chain(*x))
  4.  
  5. def bytesplit2(n):
  6. return [n>>8,n&0xFF]
  7.  
  8. def bytesplit3(n):
  9. x = list(bytesplit2(n))
  10. x[0] = bytesplit2(x[0])
  11. x[1] = [x[1]] # need to do this for flatten to work
  12. return flatten(x)
  13.  
  14. class Pokemon:
  15. def __init__(self):
  16. self.species = 0x00 # Species ID
  17. self.hp = 0x0000 # HP (16-bit big endian (the rest of the system uses little-endian???))
  18. self.boxlevel = 0x00 # Box Level (Pretty sure this is always 0 unless the 'mon's in the box, but oh well)
  19. self.status = 0x00 # Status Conditions (bitfield)
  20. self.types = [0x00,0x00] # Type 1 and Type 2 (same in single-typed 'mons)
  21. self.catchrate = 0x00 # Catch rate of original species (co-opted in Gen 2 for held item)
  22. self.moves = [0x00,0x00,0x00,0x00] # Move IDs
  23. self.otid = 0x0000 # ID of OT
  24. self.xp = 0x000000 # Main XP
  25. self.sxp = [0x0000 for x in range(5)] # Stat XP (HP, ATK, DEF, SPD, Special)
  26. self.dv = [0x00,0x00] # DVs (one nibble for each of Attack, Defense, Speed, Special)
  27. self.pp = [0x00,0x00,0x00,0x00] # PP for each move
  28. self.level = 0x00
  29. self.stathp = 0x0000 # max HP
  30. self.statatk = 0x0000 # attack stat
  31. self.statdef = 0x0000 # defense stat
  32. self.statspd = 0x0000 # speed stat
  33. self.statspl = 0x0000 # special stat
  34.  
  35. def getBytes(self):
  36. return [self.species]+bytesplit2(self.hp)+[self.boxlevel,self.status]+self.types+[self.catchrate]+self.moves+bytesplit2(self.otid)+bytesplit3(self.xp)+[bytesplit2(x) for x in self.sxp]+self.dv+self.pp+[self.level]
  37.  
  38. def stats(self):
  39. return flatten([bytesplit2(x) for x in (self.stathp,self.statatk,self.statdef,self.statspd,self.statspl)])
Advertisement
Add Comment
Please, Sign In to add comment