mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
![Merijn Hendriks](/assets/img/avatar_default.png)
Requires server-side changes (will need your help @TheSparta for this!). This combined all the single bot difficulty requests into a single GET request (`/singleplayer/bot/difficulties`) with the following data structure: ```json [ { "role": "assault", "difficulty": "easy", "data": "assets/database/bots/types/assault.json difficulty easy contents" }, { "role": "pmcbot", "difficulty": "normal", "data": "assets/database/bots/types/pmcbot.json difficulty normal contents" } ] ``` The request expects all roles and all their respective difficulties to be in the response. Co-authored-by: Merijn Hendriks <merijnhendriks@users.noreply.github.com> Reviewed-on: SPT-AKI/Modules#111 Reviewed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-authored-by: Merijn Hendriks <senko-san@noreply.dev.sp-tarkov.com> Co-committed-by: Merijn Hendriks <senko-san@noreply.dev.sp-tarkov.com>
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using Aki.Custom.Utils;
|
|
using Aki.Reflection.Patching;
|
|
using Aki.Reflection.Utils;
|
|
using EFT;
|
|
using EFT.UI;
|
|
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.SingleCustom(x => x.GetMethod(methodName, flags) != null)
|
|
.GetMethod(methodName, flags);
|
|
}
|
|
|
|
[PatchPrefix]
|
|
private static bool PatchPrefix(ref string __result, BotDifficulty botDifficulty, WildSpawnType role)
|
|
{
|
|
__result = DifficultyManager.Get(botDifficulty, role);
|
|
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
|
|
}
|
|
}
|
|
}
|