FreddyEnemy Patch
An unofficial compatibility patch for OrtonLongGaming's Freddy Enemy mod. Fixes critical crashes and restores AI/Audio logic. Tested on R.E.P.O. v0.4.4.x.
模組介紹 作者原文
FreddyEnemy Patch - Unofficial Compatibility Patch
An unofficial hotfix for the FreddyEnemy mod by OrtonLongGaming.
Link to the original mod page
Compatibility: Tested and working on R.E.P.O. version 0.4.4.x. Other game versions have not been tested and are not guaranteed to work.
Due to recent R.E.P.O. game updates, the original mod causes severe NullReferenceException errors, leading to broken AI and missing sounds. This patch dynamically intercepts and fixes the broken code in the game's RAM, bringing Freddy Fazbear back to life without modifying or reuploading the original mod assets.
Summary of Changes
- Restored Attack Logic: Fixed the critical crash that occurred whenever Freddy attempted to attack a player.
- Restored Audio Loops: Fixed the crashes caused by Freddy's Stunned, Haywire, and Cloaked sound effects.
- Stuck/Pathfinding Fix: Ensured Freddy's StuckCount resets correctly so he doesn't get permanently stuck on the map.
- Surgical Compatibility: The patch automatically scans for and removes old or conflicting patches targeting Freddy before applying itself, preventing mod conflicts.
Installation
Use a Mod Manager (Recommended):
Simply click "Install with Mod Manager". The original FreddyEnemy mod will be downloaded automatically as a required dependency.
Manual Installation:
- Install BepInEx.
- Install the original FreddyEnemy mod.
- Drop the FreddyEnemy_Patch.dll into your BepInEx/plugins folder.
Technical Details for Developers
Recent R.E.P.O. updates introduced breaking signature changes to core game methods, most notably PlayerHealth.HurtOther and Sound.PlayLoop (both updated to require 5 arguments instead of 4).
Because the original mod's compiled assembly references the outdated signatures, attempting to patch the broken methods (HandleAttack, SfxStunnedLoop, etc.) directly causes Harmony to throw an IL Compile Error (ArgumentNullException: Invalid argument for callvirt NULL). The engine crashes simply by trying to read the broken IL instructions.
To bypass this issue cleanly, this patch uses a Surgical Transpiler approach:
- Parent Interception: Instead of patching the broken methods, HarmonyTranspiler is applied to their parent methods (EnemyFreddy.Update and EnemyFreddyAnim.Update).
- Call Rerouting: The transpilers scan for OpCodes.Call instructions pointing to the broken methods, erase them, and reroute the execution flow to custom static C# methods within the patch.
- Reflection via Traverse: The custom methods rebuild the attack and audio logic from scratch. Harmony's Traverse class is used to dynamically resolve private fields (_stateImpulse, _enemy, _sfxStunnedLoop) and bypass compiler restrictions for hidden variables like StuckCount, effectively injecting the updated 5-argument method calls safely.
- Pre-patch Cleanup: Uses Harmony.GetPatchInfo to unpatch any potentially conflicting third-party modifications to Freddy's logic before applying the fixes.
Thanks
OrtonLongGaming for creating this fantastic original FreddyEnemy mod.
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: