mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 05:30:43 -05:00
Create an exfil dumper patch for aki-debugging (!98)
This patch can be used to dump the data contained in the `allExtracts.json` files in the server locations database. When enabled, load into each map sequentially, and the extract data will be dumped to `ExfilDumps/{mapName}/allExtracts.json`, ready to be copy/pasted into the server `database/locations` directory Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: SPT-AKI/Modules#98 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
8443e6b5d3
commit
497e581c1e
@ -21,7 +21,8 @@ namespace Aki.Debugging
|
||||
new EndRaidDebug().Enable();
|
||||
new LoggerClassLogPatch().Enable();
|
||||
// new CoordinatesPatch().Enable();
|
||||
// new StaticLootDumper().Enable();
|
||||
// new StaticLootDumper().Enable();
|
||||
// new ExfilDumper().Enable();
|
||||
|
||||
// BTR debug command patches, can be disabled later
|
||||
//new BTRDebugCommandPatch().Enable();
|
||||
|
140
project/Aki.Debugging/Patches/ExfilDumper.cs
Normal file
140
project/Aki.Debugging/Patches/ExfilDumper.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
using EFT.Interactive;
|
||||
using EFT.InventoryLogic;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ExitSettingsClass = GClass1225;
|
||||
|
||||
namespace Aki.Debugging.Patches
|
||||
{
|
||||
internal class ExfilDumper : ModulePatch
|
||||
{
|
||||
public static string DumpFolder = Path.Combine(Environment.CurrentDirectory, "ExfilDumps");
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(ExfiltrationControllerClass).GetMethod(nameof(ExfiltrationControllerClass.InitAllExfiltrationPoints));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void PatchPreFix(ExitSettingsClass[] settings)
|
||||
{
|
||||
var gameWorld = Singleton<GameWorld>.Instance;
|
||||
string mapName = gameWorld.MainPlayer.Location.ToLower();
|
||||
|
||||
var pmcExfilPoints = ExfiltrationControllerClass.Instance.ExfiltrationPoints;
|
||||
|
||||
// Both scav and PMC lists include shared, so remove them from the scav list
|
||||
var scavExfilPoints = ExfiltrationControllerClass.Instance.ScavExfiltrationPoints.Where(x => !(x is SharedExfiltrationPoint));
|
||||
|
||||
var exfils = new List<SPTExfilData>();
|
||||
|
||||
foreach (var exfil in pmcExfilPoints.Concat(scavExfilPoints))
|
||||
{
|
||||
ExitSettingsClass exitSettings = settings.FirstOrDefault(x => x.Name == exfil.Settings.Name);
|
||||
exfils.Add(new SPTExfilData(exfil, exitSettings));
|
||||
}
|
||||
|
||||
string jsonString = JsonConvert.SerializeObject(exfils, Formatting.Indented);
|
||||
string outputFile = Path.Combine(DumpFolder, mapName, "allExtracts.json");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(outputFile));
|
||||
if (File.Exists(outputFile))
|
||||
{
|
||||
File.Delete(outputFile);
|
||||
}
|
||||
File.Create(outputFile).Dispose();
|
||||
StreamWriter streamWriter = new StreamWriter(outputFile);
|
||||
streamWriter.Write(jsonString);
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
}
|
||||
|
||||
public class SPTExfilData
|
||||
{
|
||||
public float Chance = 0;
|
||||
public int Count = 0;
|
||||
public string EntryPoints = "";
|
||||
public bool EventAvailable = false;
|
||||
public float ExfiltrationTime = 0;
|
||||
public EExfiltrationType ExfiltrationType;
|
||||
public string Id = "";
|
||||
public float MinTime = 0;
|
||||
public float MaxTime = 0;
|
||||
public string Name = "";
|
||||
public ERequirementState PassageRequirement;
|
||||
public int PlayersCount = 0;
|
||||
public EquipmentSlot RequiredSlot;
|
||||
public string RequirementTip = "";
|
||||
public string Side = "";
|
||||
|
||||
public SPTExfilData(ExfiltrationPoint point, ExitSettingsClass settings)
|
||||
{
|
||||
// PMC and shared extracts, prioritize settings over the map data to match base behaviour
|
||||
if (settings != null && (!(point is ScavExfiltrationPoint) || point is SharedExfiltrationPoint))
|
||||
{
|
||||
if (settings != null)
|
||||
{
|
||||
EntryPoints = settings.EntryPoints;
|
||||
Chance = settings.Chance;
|
||||
EventAvailable = settings.EventAvailable;
|
||||
ExfiltrationTime = settings.ExfiltrationTime;
|
||||
ExfiltrationType = settings.ExfiltrationType;
|
||||
MaxTime = settings.MaxTime;
|
||||
MinTime = settings.MinTime;
|
||||
Name = settings.Name;
|
||||
PlayersCount = settings.PlayersCount;
|
||||
}
|
||||
}
|
||||
// Scav extracts, and those without settings use the point settings
|
||||
else
|
||||
{
|
||||
EntryPoints = String.Join(",", point.EligibleEntryPoints);
|
||||
Chance = point.Settings.Chance;
|
||||
EventAvailable = point.Settings.EventAvailable;
|
||||
ExfiltrationTime = point.Settings.ExfiltrationTime;
|
||||
ExfiltrationType = point.Settings.ExfiltrationType;
|
||||
MaxTime = point.Settings.MaxTime;
|
||||
MinTime = point.Settings.MinTime;
|
||||
Name = point.Settings.Name;
|
||||
PlayersCount = point.Settings.PlayersCount;
|
||||
}
|
||||
|
||||
// If there's settings, and the requirement is a reference, use that
|
||||
if (settings?.PassageRequirement == ERequirementState.Reference)
|
||||
{
|
||||
PassageRequirement = ERequirementState.Reference;
|
||||
Id = settings.Id;
|
||||
}
|
||||
// Otherwise use the point requirements
|
||||
else if (point.HasRequirements)
|
||||
{
|
||||
Count = point.Requirements[0].Count;
|
||||
Id = point.Requirements[0].Id;
|
||||
PassageRequirement = point.Requirements[0].Requirement;
|
||||
RequiredSlot = point.Requirements[0].RequiredSlot;
|
||||
RequirementTip = point.Requirements[0].RequirementTip;
|
||||
}
|
||||
|
||||
// Store the side
|
||||
if (point is SharedExfiltrationPoint)
|
||||
{
|
||||
Side = "Coop";
|
||||
}
|
||||
else if (point is ScavExfiltrationPoint)
|
||||
{
|
||||
Side = "Scav";
|
||||
}
|
||||
else
|
||||
{
|
||||
Side = "Pmc";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user