Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- with open('move_table.c') as f:
- content = f.readlines()
- f = open('2move_table.c', 'w')
- for line in content:
- lin = line.strip()
- if len(lin) == 0 or lin[0] != '{':
- f.write( line )
- if line.startswith('const '):
- f.write( '// script_id base_power type accuracy pp effect_chance target priority move_flags arg1 split arg2\n' )
- else:
- lin = lin.split(',')
- nlin = ' {'
- hexc = "0x%0.2X"
- decc = "%3s"
- def get_checking_str(val):
- val = val.strip()
- if val[0].isdigit():
- return hexc % int(val, 0 )
- else:
- return val
- #script_id
- num = hexc % int( lin[0][1:] , 0 )
- nlin += num
- nlin += ', '
- #base_power
- num = decc % int( lin[1].strip() , 0 )
- nlin += num
- nlin += ', '
- #type
- lin[2] = lin[2].strip()
- if not lin[2][0].isdigit():
- ptype = lin[2]
- else:
- num = int( lin[2].strip() , 0 )
- if num == 0x0:
- ptype = 'TYPE_NORMAL'
- elif num == 0x1:
- ptype = 'TYPE_FIGHTING'
- elif num == 0x2:
- ptype = 'TYPE_FLYING'
- elif num == 0x3:
- ptype = 'TYPE_POISON'
- elif num == 0x4:
- ptype = 'TYPE_GROUND'
- elif num == 0x5:
- ptype = 'TYPE_ROCK'
- elif num == 0x6:
- ptype = 'TYPE_BUG'
- elif num == 0x7:
- ptype = 'TYPE_GHOST'
- elif num == 0x8:
- ptype = 'TYPE_STEEL'
- elif num == 0x9:
- ptype = 'TYPE_EGG'
- elif num == 0xA:
- ptype = 'TYPE_FIRE'
- elif num == 0xB:
- ptype = 'TYPE_WATER'
- elif num == 0xC:
- ptype = 'TYPE_GRASS'
- elif num == 0xD:
- ptype = 'TYPE_ELECTRIC'
- elif num == 0xE:
- ptype = 'TYPE_PSYCHIC'
- elif num == 0xF:
- ptype = 'TYPE_ICE'
- elif num == 0x10:
- ptype = 'TYPE_DRAGON'
- elif num == 0x11:
- ptype = 'TYPE_DARK'
- elif num == 0x17:
- ptype = 'TYPE_FAIRY'
- ptype = "%13s" % ptype
- nlin += ptype
- nlin += ', '
- #accuracy
- num = decc % int( lin[3].strip() , 0 )
- nlin += num
- nlin += ', '
- #pp
- num = decc % int( lin[4].strip() , 0 )
- nlin += num
- nlin += ', '
- #effect_chance
- num = decc % int( lin[5].strip() , 0 )
- nlin += num
- nlin += ', '
- #target
- num = hexc % int( lin[6].strip() , 0 )
- nlin += num
- nlin += ', '
- #priority
- num = int( lin[7].strip() , 0 )
- if num >= 128:
- num -= 256
- num = decc % num
- nlin += num
- nlin += ', '
- #move_flags
- nlin += lin[8].strip()
- nlin += ', '
- #arg1
- nlin += get_checking_str(lin[9])
- nlin += ', '
- #split
- lin[10] = lin[10].strip()
- if not lin[10][0].isdigit():
- mtype = lin[10]
- else:
- num = int( lin[10].strip() , 0 )
- if num == 0:
- mtype = 'MOVE_PHYSICAL'
- elif num == 1:
- mtype = 'MOVE_SPECIAL'
- elif num == 2:
- mtype = 'MOVE_STATUS'
- mtype = "%13s" % mtype
- nlin += mtype
- nlin += ', '
- if len(lin) == 13:
- #arg2
- nlin += get_checking_str(lin[11].strip()[0:-1])
- nlin += '},'
- nlin += lin[12]
- else:
- nlin += lin[11].strip()
- nlin += '\n'
- f.write( nlin )
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement