Guest User

Robot Arena 2: Component Freedom v2.1

a guest
Aug 13th, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. ### Configuration starts here
  2. # Comment out / remove any of the lines 4-7? to disable a mod.
  3. ENABLED_MODS = [
  4. "unlimited mass", # no mass limit
  5. "unlimited chains", # disable 7-chain rule
  6. "chassis points", # disables 16-point chassis limit
  7. # "attachment hermaphroditism", # attach components to any type of AP, disabled by default
  8. # "component intersection", # allow components to intersect any other component, disabled by default
  9. ]
  10. # Logfile name
  11. LOGFILE = 'sergepatcher_log.txt'
  12. ### Configuration ends here
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. # / this space intentionally left blank ... /
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. # Anything underneath is pretty much internal, not much will come of randomly
  35. # messing around with it...
  36.  
  37. def error(message):
  38. f = open(LOGFILE, "a")
  39. f.write(' ERR ' + message + '\n')
  40. f.close()
  41. #sergepatcher.mbox('sergepatcher error', message)
  42.  
  43. def info(message):
  44. f = open(LOGFILE, "a")
  45. f.write('INFO ' + message + '\n')
  46. f.close()
  47.  
  48. class Mod(object):
  49. """Container for a mod to be applied, which consists of series of patches
  50. to the running binary."""
  51. def __init__(self, name):
  52. self.name = name
  53. self.patches = []
  54.  
  55. def __str__(self):
  56. return "<Mod %s, %i patche(s)>" % (self.name, len(self.patches))
  57.  
  58. def add_patch(self, where, what):
  59. """Add replacement patch (replace @what bytes at @where)."""
  60. self.patches.append((what, where, len(what)))
  61. return self
  62.  
  63. def add_string_patch(self, where, what):
  64. """Add null-terminated patch (replace @what bytes at @where)."""
  65. self.patches.append((what, where, len(what)+1))
  66. return self
  67.  
  68. def apply(self):
  69. """Apply internal patches to game binary."""
  70. for (what, where, l) in self.patches:
  71. if not sergepatcher.setw(where, l):
  72. return False
  73. sergepatcher.patch(where, what, l)
  74. return True
  75.  
  76. def main():
  77. h = sergepatcher.getmd5()
  78. if h != "47bce5c74f589f4867dbd57e9ca9f88":
  79. error('Sergepatcher is only compatible with RA2 v14.')
  80. return
  81. enabled = []
  82. for m in ENABLED_MODS:
  83. if m not in MODS:
  84. error("Mod '%s' does not exist! Skipping." % m)
  85. continue
  86. m = MODS[m]
  87. if m.apply():
  88. info("Mod '%s' applied succesfully." % m.name)
  89. enabled.append(m.name)
  90. else:
  91. error("Failed to apply mod %s!" % m.name)
  92.  
  93. text = "RA2:CF enabled mods: "
  94. text += ', '.join(enabled)
  95. text += '. Have fun!'
  96. (Mod("information")
  97. .add_string_patch(0x6f16b0, text)
  98. .apply())
  99. info('Initialized succesfully!')
  100.  
  101. MODS = {}
  102. def add_mod(m):
  103. MODS[m.name] = m
  104.  
  105. add_mod(Mod("unlimited mass")
  106. .add_patch(0x42f7ba, "\xEB\x06"))
  107. add_mod(Mod("unlimited chains")
  108. .add_patch(0x45e9f0, "\x90\x90\x90\x90\x90\x90"))
  109. add_mod(Mod("attachment hermaphroditism")
  110. .add_patch(0x45c515, "\xb0\x01"))
  111. add_mod(Mod("component intersection")
  112. .add_patch(0x42cecb, "\xb0\x01\x90")
  113. .add_patch(0x42d0c0, "\x01"))
  114. add_mod(Mod("chassis points")
  115. .add_patch(0x478fae, "\x90\x90\x90\x90\x90\x90"))
  116.  
  117. # Zero out logfile
  118. open(LOGFILE, 'w').close()
  119. info('Starting...')
  120. try:
  121. import sergepatcher
  122. main()
  123. except Exception, e:
  124. error('Exception in main block!')
  125. error(str(e))
Add Comment
Please, Sign In to add comment