2024-05-21 19:10:17 +01:00
|
|
|
using SPT.Custom.Utils;
|
|
|
|
using SPT.Reflection.Patching;
|
|
|
|
using SPT.Reflection.Utils;
|
2023-03-03 18:52:31 +00:00
|
|
|
using EFT;
|
2023-10-10 10:58:33 +00:00
|
|
|
using EFT.UI;
|
2023-03-03 18:52:31 +00:00
|
|
|
using System.Reflection;
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
namespace SPT.Custom.Patches
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
|
|
|
public class BotDifficultyPatch : ModulePatch
|
|
|
|
{
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
{
|
2024-08-28 12:52:54 +01:00
|
|
|
const string methodName = "LoadDifficultyStringInternal";
|
|
|
|
const BindingFlags flags = BindingFlags.Public | BindingFlags.Static;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
2024-01-13 22:08:29 +00:00
|
|
|
return PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null)
|
2023-03-03 18:52:31 +00:00
|
|
|
.GetMethod(methodName, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
[PatchPrefix]
|
2024-08-02 16:57:59 +01:00
|
|
|
public static bool PatchPrefix(ref string __result, BotDifficulty botDifficulty, WildSpawnType role)
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
2024-04-20 22:32:28 +00:00
|
|
|
__result = DifficultyManager.Get(botDifficulty, role);
|
2023-10-10 10:58:33 +00:00
|
|
|
var resultIsNullEmpty = string.IsNullOrWhiteSpace(__result);
|
|
|
|
if (resultIsNullEmpty)
|
|
|
|
{
|
|
|
|
ConsoleScreen.LogError($"Unable to get difficulty settings for {role} {botDifficulty}");
|
2024-10-03 10:28:48 +01:00
|
|
|
|
|
|
|
return true; // Do original method
|
2023-10-10 10:58:33 +00:00
|
|
|
}
|
|
|
|
|
2024-10-03 10:28:48 +01:00
|
|
|
return false; // Skip original
|
2023-03-03 18:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|