FenixPK added a new file:
QuoteDisplay MoreThis mod is simply a BepInEx plugin that uses AKI.Reflection (Harmony) to PrefixPatch the "IsEnemyLookingAtMe" method that the game uses in a few places eg. ShallAttack() and EndHoldPosition() and return false instead of evaluating.
There are config options accessed via in-game menu F12 but the game must be restarted for them to take effect.
You can turn on the ESP override for Players, and/or for Bots. When the Player override is enabled it means a Bot won't know when a player is looking at it, but will know when another Bot is. When the Bot override is enabled it means a Bot won't know when another Bot is looking at it but will when a player is. And when both checkboxes are enabled it means a Bot won't know when either a Bot or a Player is looking at it.
I've used ILSpy to try and figure out where this function is used and it seems to me ShallAttack and EndHoldPosition are the only places, and there are other triggers for going into attack mode. For eg. bots will still spot you first if you are within their view distance. They react to being shot at and add danger points to investigate etc. I've had the whole map swarm my location after opening fire with a loud rifle with this enabled. I've been chased down and shot in the back many times even with this on too. Bots still engage each other in firefights with both settings enabled but I haven't done enough testing to see if there are any issues with turning it off for bots too, hence the config options.
I have had a ton of fun crawling through the grass on woods and taking my time to line up shots on AI moving far away. Waiting for them to get caught up in brush up ahead and slow down before pulling the trigger. Or waiting for them to finish wandering through terrain that goes up and down a lot before taking the shot etc. Prior to this as soon as my crosshair went over their body they turned to aim at me and attack. Even if I was aiming at a stationary AI with their back turned to me. It was driving me crazy.
IMPORTANT NOTE:
I play with Fin's AI Tweaks and AI Loader with fairly close to default values for most settings. I have not tested my mod with vanilla AI. The reason I made this mod is because even after tweaking all the AI look/aiming/mind variables with Fins I still couldn't get them to stop this ESP behaviour. I've set the values back to Fin defaults and the game is a lot more fun while remaining challenging.
COMPATIBILITY:
As far as I know this should be forwards and backwards compatible so long as the method isn't re-named or moved. It currently resides in EFT.BotOwner. I may need to update references and re-compile, not sure. If anyone has issues running this on 3.2.0 let me know and I'll update.
KNOWN ISSUES:
I have had one occasion where a Bot I had fired at around 100m away took cover behind a bush and just stared at me without attacking. Once I looted him I realized he just had a pistol, so it was likely because I was out of his engagement range. However I believe with ESP still enabled he would have ended his hold position loop when I aimed down sights at him instead of just staring at me. Whether that means he rushed me or just found better cover I don't know.
I personally am OK with this because
1) most times they have a rifle and will engage at that distance.
2) Without ESP disabled they would still just stare at you until you aimed-down-sights anyway (The check in code is player.GetPlayer.HandsController.IsAiming && bot.IsEnemyLookingAtMe(player) so you have to be aim down sights not just looking at them)
3) If you fire at them they do react.
SOURCE CODE:
I for some reason cannot receive the registration email for dev.sp-tarkov sign up so I've put the source code on GitHub for now. Feel free to peek around and see what I did. If someone wants to take a crack at properly overriding the method to take distance and angle into account so they will notice if you look at them ONLY if they are also looking at you and reasonably close enough to see you that would be great. I might get around to it, but vectors and angles are not my strong suit. Calculus class was 11 years ago for me now haha.
SPECIAL THANKS:
I have to thank Fin with Fin's AI Loader and AI Tweaks for getting me looking at the AI variables. If it wasn't for that configurability I wouldn't have realized this was NOT just an AI variable you could tweak (ENEMY_LOOK_AT_ME_ANG for eg changes nothing about AI ESP regardless of the value I put in there).
Also SamSWAT for his FOV tweak and weather tweak which got me looking at BepInEx and how he patched the game with it. Without his source code I wouldn't have learned you could even do this. Before reading into his changes I didn't even know Harmony existed or that AKI.Reflection uses it. I'm into a whole new world of holy crap you can do that?! In fact what started all this was trying to make an FOV mod that made aim-down-sights more zoomed in for myself (haven't figured that one out yet).
And of course the AKI team for their great documentation and examples of using AKI.Reflection.
And the HarmonyLib team for their documentation on how PreFix and PostFix patches work etc.