mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 02:30:44 -05:00
fix: difficulties response parsing (!113)
fixed bot difficulties model to match server response for `/singleplayer/settings/bot/difficulties` also bumps up the sptBear and sptUsec enums so they don't collide with new pmcUSEC and pmcBEAR Reviewed-on: SPT-AKI/Modules#113 Co-authored-by: kiobu <kiobu@sdf.org> Co-committed-by: kiobu <kiobu@sdf.org>
This commit is contained in:
parent
2abc1ab0ce
commit
cc2377bf72
@ -77,6 +77,7 @@ namespace Aki.Custom
|
||||
new CultistAmuletRemovalPatch().Enable();
|
||||
new HalloweenExtractPatch().Enable();
|
||||
new ClampRagdollPatch().Enable();
|
||||
new DisablePvEPatch().Enable();
|
||||
|
||||
HookObject.AddOrGetComponent<MenuNotificationManager>();
|
||||
}
|
||||
|
@ -1,24 +1,43 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Aki.Custom.Models
|
||||
{
|
||||
[DataContract]
|
||||
[Serializable]
|
||||
public struct DifficultyInfo
|
||||
{
|
||||
[DataMember(Name = "role")]
|
||||
public string Role;
|
||||
|
||||
[DataMember(Name = "difficulty")]
|
||||
public string Difficulty;
|
||||
|
||||
[DataMember(Name = "data")]
|
||||
public string Data;
|
||||
|
||||
public DifficultyInfo(string role, string difficulty, string data)
|
||||
public Dictionary<string, object> this[string key]
|
||||
{
|
||||
Role = role;
|
||||
Difficulty = difficulty;
|
||||
Data = data;
|
||||
get
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "easy":
|
||||
return easy;
|
||||
case "hard":
|
||||
return hard;
|
||||
case "impossible":
|
||||
return impossible;
|
||||
case "normal":
|
||||
return normal;
|
||||
default:
|
||||
throw new ArgumentException($"Difficulty '{key}' does not exist in DifficultyInfo.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty("easy")]
|
||||
public Dictionary<string, object> easy;
|
||||
|
||||
[JsonProperty("hard")]
|
||||
public Dictionary<string, object> hard;
|
||||
|
||||
[JsonProperty("impossible")]
|
||||
public Dictionary<string, object> impossible;
|
||||
|
||||
[JsonProperty("normal")]
|
||||
public Dictionary<string, object> normal;
|
||||
}
|
||||
}
|
@ -20,8 +20,8 @@ namespace Aki.Custom.Patches
|
||||
[PatchPrefix]
|
||||
private static bool PatchPrefix(ref string __result)
|
||||
{
|
||||
// core difficulty is requested before the others
|
||||
// so update the others now!
|
||||
// fetch all bot difficulties to be used in BotDifficultyPatch
|
||||
// this is called here since core difficulties are fetched before bot-specific difficulties are
|
||||
DifficultyManager.Update();
|
||||
|
||||
// update core difficulty
|
||||
|
28
project/Aki.Custom/Patches/DisablePvEPatch.cs
Normal file
28
project/Aki.Custom/Patches/DisablePvEPatch.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Aki.Common.Http;
|
||||
using Aki.Reflection.Patching;
|
||||
using System.Reflection;
|
||||
using EFT;
|
||||
using EFT.UI;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aki.Custom.Patches
|
||||
{
|
||||
public class DisablePvEPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(ChangeGameModeButton), nameof(ChangeGameModeButton.Show));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
private static bool PatchPrefix(ESessionMode sessionMode, Profile profile, ref GameObject ____notAvailableState)
|
||||
{
|
||||
____notAvailableState.SetActive(true);
|
||||
Object.FindObjectsOfType<HoverTooltipArea>().Where(o => o.name == "Locked").Single().SetMessageText("<color=#51c6db>SPT-AKI</color> is already PvE.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,11 +8,11 @@ namespace Aki.Custom.Utils
|
||||
{
|
||||
public static class DifficultyManager
|
||||
{
|
||||
public static List<DifficultyInfo> Difficulties { get; private set; }
|
||||
public static Dictionary<string, DifficultyInfo> Difficulties { get; private set; }
|
||||
|
||||
static DifficultyManager()
|
||||
{
|
||||
Difficulties = new List<DifficultyInfo>();
|
||||
Difficulties = new Dictionary<string, DifficultyInfo>();
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
@ -22,21 +22,13 @@ namespace Aki.Custom.Utils
|
||||
|
||||
// get new difficulties
|
||||
var json = RequestHandler.GetJson("/singleplayer/settings/bot/difficulties");
|
||||
Difficulties = Json.Deserialize<List<DifficultyInfo>>(json);
|
||||
Difficulties = Json.Deserialize<Dictionary<string, DifficultyInfo>>(json);
|
||||
}
|
||||
|
||||
public static string Get(BotDifficulty botDifficulty, WildSpawnType role)
|
||||
{
|
||||
foreach (var entry in Difficulties)
|
||||
{
|
||||
if (botDifficulty.ToString().ToLower() == entry.Difficulty
|
||||
&& role.ToString().ToLower() == entry.Role)
|
||||
{
|
||||
return entry.Data;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
var difficultyMatrix = Difficulties[role.ToString().ToLower()];
|
||||
return Json.Serialize(difficultyMatrix[botDifficulty.ToString().ToLower()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ namespace Aki.PrePatch
|
||||
{
|
||||
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
|
||||
|
||||
public static int sptUsecValue = 49;
|
||||
public static int sptBearValue = 50;
|
||||
public static int sptUsecValue = 51;
|
||||
public static int sptBearValue = 52;
|
||||
|
||||
private static string _sptPluginFolder = "plugins/spt";
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace Aki.SinglePlayer.Patches.ScavMode
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
// `MatchMakerSelectionLocationScreen` OnShowNextScreen
|
||||
return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_71));
|
||||
return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_70));
|
||||
}
|
||||
|
||||
[PatchTranspiler]
|
||||
|
Loading…
x
Reference in New Issue
Block a user