Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Configuration starts here
- # Comment out / remove any of the lines 4-7? to disable a mod.
- ENABLED_MODS = [
- "unlimited mass", # no mass limit
- "unlimited chains", # disable 7-chain rule
- "chassis points", # disables 16-point chassis limit
- # "attachment hermaphroditism", # attach components to any type of AP, disabled by default
- # "component intersection", # allow components to intersect any other component, disabled by default
- ]
- # Logfile name
- LOGFILE = 'sergepatcher_log.txt'
- ### Configuration ends here
- # / this space intentionally left blank ... /
- # Anything underneath is pretty much internal, not much will come of randomly
- # messing around with it...
- def error(message):
- f = open(LOGFILE, "a")
- f.write(' ERR ' + message + '\n')
- f.close()
- #sergepatcher.mbox('sergepatcher error', message)
- def info(message):
- f = open(LOGFILE, "a")
- f.write('INFO ' + message + '\n')
- f.close()
- class Mod(object):
- """Container for a mod to be applied, which consists of series of patches
- to the running binary."""
- def __init__(self, name):
- self.name = name
- self.patches = []
- def __str__(self):
- return "<Mod %s, %i patche(s)>" % (self.name, len(self.patches))
- def add_patch(self, where, what):
- """Add replacement patch (replace @what bytes at @where)."""
- self.patches.append((what, where, len(what)))
- return self
- def add_string_patch(self, where, what):
- """Add null-terminated patch (replace @what bytes at @where)."""
- self.patches.append((what, where, len(what)+1))
- return self
- def apply(self):
- """Apply internal patches to game binary."""
- for (what, where, l) in self.patches:
- if not sergepatcher.setw(where, l):
- return False
- sergepatcher.patch(where, what, l)
- return True
- def main():
- h = sergepatcher.getmd5()
- if h != "47bce5c74f589f4867dbd57e9ca9f88":
- error('Sergepatcher is only compatible with RA2 v14.')
- return
- enabled = []
- for m in ENABLED_MODS:
- if m not in MODS:
- error("Mod '%s' does not exist! Skipping." % m)
- continue
- m = MODS[m]
- if m.apply():
- info("Mod '%s' applied succesfully." % m.name)
- enabled.append(m.name)
- else:
- error("Failed to apply mod %s!" % m.name)
- text = "RA2:CF enabled mods: "
- text += ', '.join(enabled)
- text += '. Have fun!'
- (Mod("information")
- .add_string_patch(0x6f16b0, text)
- .apply())
- info('Initialized succesfully!')
- MODS = {}
- def add_mod(m):
- MODS[m.name] = m
- add_mod(Mod("unlimited mass")
- .add_patch(0x42f7ba, "\xEB\x06"))
- add_mod(Mod("unlimited chains")
- .add_patch(0x45e9f0, "\x90\x90\x90\x90\x90\x90"))
- add_mod(Mod("attachment hermaphroditism")
- .add_patch(0x45c515, "\xb0\x01"))
- add_mod(Mod("component intersection")
- .add_patch(0x42cecb, "\xb0\x01\x90")
- .add_patch(0x42d0c0, "\x01"))
- add_mod(Mod("chassis points")
- .add_patch(0x478fae, "\x90\x90\x90\x90\x90\x90"))
- # Zero out logfile
- open(LOGFILE, 'w').close()
- info('Starting...')
- try:
- import sergepatcher
- main()
- except Exception, e:
- error('Exception in main block!')
- error(str(e))
Add Comment
Please, Sign In to add comment