From d8c0abfe040fb65faad5cc073a6cba782099d605 Mon Sep 17 00:00:00 2001 From: Lacyway Date: Thu, 17 Oct 2024 16:32:40 +0000 Subject: [PATCH] Add FirearmControllerShowIncompatibleNotificationClass (!171) This patch aims to prevent the player from incorrectly receiving the incompatible ammo notification if an AI fails to shoot because of incompatible ammo. Tested with no errors, should probably be added and let users report whether it still occurs as it is hard to reliably reproduce. Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT/Modules/pulls/171 Co-authored-by: Lacyway Co-committed-by: Lacyway --- ...rollerShowIncompatibleNotificationClass.cs | 23 +++++++++++++++++++ .../SPT.SinglePlayer/SPTSingleplayerPlugin.cs | 1 + 2 files changed, 24 insertions(+) create mode 100644 project/SPT.SinglePlayer/Patches/RaidFix/FirearmControllerShowIncompatibleNotificationClass.cs diff --git a/project/SPT.SinglePlayer/Patches/RaidFix/FirearmControllerShowIncompatibleNotificationClass.cs b/project/SPT.SinglePlayer/Patches/RaidFix/FirearmControllerShowIncompatibleNotificationClass.cs new file mode 100644 index 0000000..8290bb1 --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/RaidFix/FirearmControllerShowIncompatibleNotificationClass.cs @@ -0,0 +1,23 @@ +using EFT; +using SPT.Reflection.Patching; +using System.Reflection; + +namespace SPT.SinglePlayer.Patches.RaidFix +{ + /// + /// This patch stops the player from receiving the incompatible ammo notification if it's triggered by an AI + /// + public class FirearmControllerShowIncompatibleNotificationClass : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(Player.FirearmController.GClass1748).GetMethod(nameof(Player.FirearmController.GClass1748.ShowIncompatibleNotification)); + } + + [PatchPrefix] + public static bool Prefix(Player ___player_0) + { + return ___player_0.IsYourPlayer; + } + } +} diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index 3196f61..7b862d2 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -62,6 +62,7 @@ namespace SPT.SinglePlayer new FixLocalRaidPatch().Enable(); new ScavIsPlayerEnemyPatch().Enable(); new BotOwnerManualUpdatePatch().Enable(); + new FirearmControllerShowIncompatibleNotificationClass().Enable(); } catch (Exception ex) {