0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/Patches/BotDifficultyPatch.cs
chomp 1e238c426e 0.13.5.0 (!33)
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Co-authored-by: CWX <CWX@noreply.dev.sp-tarkov.com>
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-authored-by: RaiRaiTheRaichu <rairaitheraichu@noreply.dev.sp-tarkov.com>
Co-authored-by: CWX <cwx@noreply.dev.sp-tarkov.com>
Co-authored-by: Kaeno <e>
Reviewed-on: SPT-AKI/Modules#33
2023-10-10 10:58:33 +00:00

36 lines
1.1 KiB
C#

using Aki.Common.Http;
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using EFT;
using EFT.UI;
using System.Linq;
using System.Reflection;
namespace Aki.Custom.Patches
{
public class BotDifficultyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
var methodName = "LoadDifficultyStringInternal";
var flags = BindingFlags.Public | BindingFlags.Static;
return PatchConstants.EftTypes.Single(x => x.GetMethod(methodName, flags) != null)
.GetMethod(methodName, flags);
}
[PatchPrefix]
private static bool PatchPrefix(ref string __result, BotDifficulty botDifficulty, WildSpawnType role)
{
__result = RequestHandler.GetJson($"/singleplayer/settings/bot/difficulty/{role}/{botDifficulty}");
var resultIsNullEmpty = string.IsNullOrWhiteSpace(__result);
if (resultIsNullEmpty)
{
ConsoleScreen.LogError($"Unable to get difficulty settings for {role} {botDifficulty}");
}
return resultIsNullEmpty; // Server data returned = false = skip original method
}
}
}