Advertisement
Appendko

新仙劍 0exp Gmon.dat Generator

Feb 13th, 2018
1,117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. #Python Script to make 0exp GMon.dat
  2. #Author: Append Huang ([email protected])
  3. #Reference: https://www.ptt.cc/bbs/pal/M.1461154467.A.F26.html
  4. #Reference: https://goo.gl/VypRfq
  5.  
  6. #read binary file as bytearray to make modification
  7. with open("GMon.dat","rb") as f:
  8.     gmon = bytearray(f.read())
  9.  
  10. #begin from 0x200, read every 4 bytes:
  11. for i in range(0x200,len(gmon)-4):
  12.     if gmon[i:i+4] == b'\x00\xF0\xF2\x7F':
  13.         #Name: 00F0F27F_name_2525
  14.         j=i+4
  15.         while gmon[j:j+2] != b'\x25\x25':
  16.             j+=1
  17.         mon_name = gmon[i+4:j].decode(encoding='big5') #name is in big5
  18.     elif gmon[i:i+4] == b'\x01\x10\x20\x7F':
  19.         #Stats: 01 10 20 7F "Type"(1byte) 00 00 00 "EXP"(4byte)
  20.         tup_48 = tuple() #type of stats
  21.         if gmon[i+4:i+8] == b'\xBE\x00\x00\x00': #BE: Exp
  22.             #Whole Data (12byte):
  23.             #print(" ".join(["%02X"]*12)%tuple(gmon[i:i+12]))
  24.             mon_exp = int.from_bytes(gmon[i+8:i+12],'little')
  25.             print("%d %s"%(mon_exp, mon_name))
  26.             # Hacking (0exp)
  27.             gmon[i+8:i+12] = (0).to_bytes(4,"little")
  28.             mon_exp = int.from_bytes(gmon[i+8:i+12],'little')
  29.             print("=> %d %s"%(mon_exp, mon_name))
  30.  
  31. #Store it back
  32. with open("GMon_0exp.dat","wb") as f:
  33.     f.write(bytes(gmon))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement