SirZer0

umvc3 mission extract

Mar 14th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. # mission_extract.py
  2. # Generates missions.txt containing all mission movelists for all characters based on the binary values in the .mis files.
  3. # Could be reversed to inject custom missions into the .mis files while keeping an intuitively formatted master file.
  4. # Could manually create an association table to moves in common notation.
  5.  
  6. import sys
  7. import binascii
  8.  
  9. start    = 0x3A8                     #First input of first mission
  10. spacing  = 0x630                     #Spacing between missions
  11. missions = []                        #List to hold missions
  12.  
  13. #Read the files
  14.  
  15. infile = sys.argv[1]                 #Takes filename from execution line
  16. fname = infile.split('.')[-3]        #Isolates path from extension
  17. fname = fname.split('/')[-1]         #Isolates filename from path
  18. charName = fname.replace('mis','')   #Isolates character name from filename
  19. print(charName)
  20. outfile = 'missions.txt'             #Output file
  21.  
  22. #Read from .mis file
  23. with open(infile,'rb') as file:
  24.  
  25.   #Start mission loop
  26.   for i in range(10):
  27.     if (i > 0): start += spacing      #move to next mission
  28.     file.seek(start)                  #set starting point for first move
  29.     mission = ''                      #initialize mission string
  30.     move = file.read(4)               #read first move of mission
  31.  
  32.     while(move[0] != '\x00'):         #repeat until invalid move
  33.       move = move.replace('\x00','')  #remove null bytes
  34.       move = binascii.hexlify(move)   #convert to hex value, not ascii value
  35.       mission += move                 #add move to mission string
  36.       mission += ' '                  #add space between inputs
  37.       move = file.read(4)             #read next move
  38.  
  39.     missions.append(mission)          #add completed mission input to mission list
  40.  
  41. j=1
  42.  
  43. #Output to file
  44. with open(outfile, 'a') as file:
  45.   file.write(charName + '\n')
  46.   for i in missions:
  47.     file.write("Mission %02d: %s\n"%(j,i))
  48.     j+=1
  49.   file.write('\n')
Advertisement
Add Comment
Please, Sign In to add comment