R.E.P.O.
Install

Details

Last Updated
First Uploaded
Downloads
440
Likes
1
Size
109KB
Dependency string
erv-FreddyEnemy_Patch-1.0.0
Dependants

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" on Thunderstore. The original FreddyEnemy mod will be downloaded automatically as a required dependency.

Manual Installation:

  1. Install BepInEx.
  2. Install the original FreddyEnemy mod.
  3. 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:

  1. Parent Interception: Instead of patching the broken methods, HarmonyTranspiler is applied to their parent methods (EnemyFreddy.Update and EnemyFreddyAnim.Update).
  2. 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.
  3. 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.
  4. 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.

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.