Advertisement
Guest User

er-patcher-animation-distance

a guest
Mar 7th, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.89 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import os
  4. import sys
  5. import subprocess
  6. import argparse
  7. from pathlib import Path
  8. import struct
  9.  
  10.  
  11. if __name__ == "__main__":
  12.  
  13.     patcher_args = sys.argv[1:sys.argv.index("--")]
  14.    
  15.     parser = argparse.ArgumentParser(description="Patch Elden Ring executable and launch it without EAC.")
  16.     parser.add_argument("-r", "--rate", type=int, default=60, help="Modify the frame rate limit (e.g. 30, 120, 165 or whatever).")
  17.     parser.add_argument("-u", "--ultrawide", action=argparse.BooleanOptionalAction, help="Removes black bars when using a resolution with an aspect ratio other than 16:9.")
  18.     parser.add_argument("-v", "--disable-vigniette", action=argparse.BooleanOptionalAction, help="Disables the vigniette overlay.")
  19.     parser.add_argument("-c", "--disable-ca", action=argparse.BooleanOptionalAction, help="Disables chromatic abberation.")
  20.     parser.add_argument("-a", "--increase-animation-distance", action=argparse.BooleanOptionalAction, help="Increase animation distance.")
  21.     patch = parser.parse_args(patcher_args)
  22.  
  23.     exe_name = Path("eldenring.exe")
  24.     with open(exe_name, "rb") as f:
  25.         exe = f.read()
  26.     exe_hex = exe.hex()
  27.  
  28.     if patch.rate != 60 and patch.rate > 0:
  29.         exe_hex = exe_hex.replace(
  30.             "c743208988883ceb43897318ebca897318",
  31.             "c743208988883ceb43897318ebca897318".replace(
  32.                 "8988883c", struct.pack('<f', 1 / patch.rate).hex()
  33.             )
  34.         )
  35.  
  36.     if patch.ultrawide:
  37.         exe_hex = exe_hex.replace(
  38.             "8b0185c07442448b5904",
  39.             "8b0185c0eb42448b5904"
  40.         )
  41.  
  42.     if patch.disable_vigniette:
  43.         exe_hex = exe_hex.replace(
  44.             "f30f590514a76e01f3440f5cc8f3450f5ecb",
  45.             "f30f590524b56e01f3440f5cc8f3450f5ecb"
  46.         )
  47.  
  48.     if patch.disable_ca:
  49.         ca_addr = 94 + exe_hex.index("0f114360488d8b800000000f1087a00000000f1141f0488d87b00000000f10080f1109")
  50.         if exe_hex[ca_addr:ca_addr + 8] == "0f114920":
  51.             exe_hex = exe_hex[:ca_addr] + "660fefc9" + exe_hex[ca_addr + 8:]  # PXOR XMM1,XMM1
  52.  
  53.     if patch.increase_animation_distance:
  54.         # DIVSS XMM1,dword ptr [R12 + 0x54] -> XORPS XMM1,XMM1; PXOR XMM1,XMM1
  55.         exe_hex = exe_hex.replace(
  56.             "e82b309c010f28f80f28c6e820359c01f30f5ef80f28cff3410f5e4c2454",
  57.             "e82b309c010f28f80f28c6e820359c01f30f5ef80f28cf0f57c9660fefc9"
  58.         )
  59.    
  60.     patched_exe_dir = Path("./er-patcher-tmp")
  61.     if not patched_exe_dir.is_dir():
  62.         patched_exe_dir.mkdir()
  63.  
  64.     with open(patched_exe_dir / exe_name, "wb") as f:
  65.         f.write(bytes.fromhex(exe_hex))
  66.  
  67.     # start patched exe directly to avoid EAC
  68.     steam_cmd = sys.argv[1 + sys.argv.index("--"):]
  69.     steam_cmd[-1] = Path(steam_cmd[-1]).parent.absolute() / patched_exe_dir / exe_name
  70.     subprocess.run(steam_cmd)
  71.  
  72.     os.remove(patched_exe_dir / exe_name)
  73.     os.rmdir(patched_exe_dir)
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement