Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # mission_extract.py
- # Generates missions.txt containing all mission movelists for all characters based on the binary values in the .mis files.
- # Could be reversed to inject custom missions into the .mis files while keeping an intuitively formatted master file.
- # Could manually create an association table to moves in common notation.
- import sys
- import binascii
- start = 0x3A8 #First input of first mission
- spacing = 0x630 #Spacing between missions
- missions = [] #List to hold missions
- #Read the files
- infile = sys.argv[1] #Takes filename from execution line
- fname = infile.split('.')[-3] #Isolates path from extension
- fname = fname.split('/')[-1] #Isolates filename from path
- charName = fname.replace('mis','') #Isolates character name from filename
- print(charName)
- outfile = 'missions.txt' #Output file
- #Read from .mis file
- with open(infile,'rb') as file:
- #Start mission loop
- for i in range(10):
- if (i > 0): start += spacing #move to next mission
- file.seek(start) #set starting point for first move
- mission = '' #initialize mission string
- move = file.read(4) #read first move of mission
- while(move[0] != '\x00'): #repeat until invalid move
- move = move.replace('\x00','') #remove null bytes
- move = binascii.hexlify(move) #convert to hex value, not ascii value
- mission += move #add move to mission string
- mission += ' ' #add space between inputs
- move = file.read(4) #read next move
- missions.append(mission) #add completed mission input to mission list
- j=1
- #Output to file
- with open(outfile, 'a') as file:
- file.write(charName + '\n')
- for i in missions:
- file.write("Mission %02d: %s\n"%(j,i))
- j+=1
- file.write('\n')
Advertisement
Add Comment
Please, Sign In to add comment