Skip to content

Instantly share code, notes, and snippets.

@sli
Created May 10, 2011 18:46
Show Gist options
  • Select an option

  • Save sli/965121 to your computer and use it in GitHub Desktop.

Select an option

Save sli/965121 to your computer and use it in GitHub Desktop.
RO Violet save file editor.
def bin_read(data):
if type(data) is type([]):
data = ''.join(data)
data = data[::-1]
return data
def bin_write(data, offset, new_data):
left = data[:offset]
right = data[offset+len(new_data):]
data = left + new_data[::-1] + right
return data
class ROVSave:
def __init__(self, filename):
self.filename = filename
self.__fp = open(filename, 'rb')
self.__fcons = self.fp.read()
self.str = bin_read(self.__fcons[68])
self.agi = bin_read(self.__fcons[70])
self.vit = bin_read(self.__fcons[72])
self.int = bin_read(self.__fcons[74])
self.dex = bin_read(self.__fcons[76])
self.luk = bin_read(self.__fcons[78])
self.zeny = bin_read(self.__fcons[170:174])
self.hp = bin_read(self.__fcons[32:33])
self.max_hp = bin_read(self.__fcons[36:37])
self.sp = bin_read(self.__fcons[39:40])
self.max_sp = bin_read(self.__fcons[43:44])
self.exp = bin_read(self.__fcons[104:108])
self.stat_points = bin_read(self.__fcons[154:158])
self.skill_points = bin_read(self.__fcons[158:162])
def save(self):
data = bin_write(self.__fcons, 68, self.str)
data = bin_write(self.__fcons, 70, self.agi)
data = bin_write(self.__fcons, 72, self.vit)
data = bin_write(self.__fcons, 74, self.int)
data = bin_write(self.__fcons, 76, self.dex)
data = bin_write(self.__fcons, 78, self.luk)
data = bin_write(self.__fcons, 170, self.zeny)
data = bin_write(self.__fcons, 32, self.hp)
data = bin_write(self.__fcons, 36, self.max_hp)
data = bin_write(self.__fcons, 39, self.sp)
data = bin_write(self.__fcons, 43, self.max_sp)
data = bin_write(self.__fcons, 104, self.exp)
data = bin_write(self.__fcons, 154, self.stat_points)
data = bin_write(self.__fcons, 158, self.skill_points)
open(self.filename, 'wb').write(self.__fcons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment