mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 22:10:45 -05:00
commit
ed5428ed88
@ -16,7 +16,7 @@ namespace Aki.Core.Utils
|
||||
var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("InstallLocation");
|
||||
var v2 = (v1 != null) ? v1.ToString() : string.Empty;
|
||||
var v3 = new DirectoryInfo(v2);
|
||||
|
||||
|
||||
var v4 = new FileSystemInfo[]
|
||||
{
|
||||
v3,
|
||||
@ -55,4 +55,4 @@ namespace Aki.Core.Utils
|
||||
return File.Exists(a) ? new FileInfo(a) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Aki.Custom.Airdrops.Models;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Aki.Custom.Airdrops.Utils
|
||||
{
|
||||
@ -34,7 +35,7 @@ namespace Aki.Custom.Airdrops.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public async void AddLoot(LootableContainer container, AirdropLootResultModel lootToAdd)
|
||||
public async Task AddLoot(LootableContainer container, AirdropLootResultModel lootToAdd)
|
||||
{
|
||||
Item actualItem;
|
||||
foreach (var item in lootToAdd.Loot)
|
||||
|
@ -16,6 +16,7 @@ namespace Aki.Custom.CustomAI
|
||||
private static readonly string throwableItemId = "543be6564bdc2df4348b4568";
|
||||
private static readonly string ammoItemId = "5485a8684bdc2da71d8b4567";
|
||||
private static readonly string weaponId = "5422acb9af1c889c16000029";
|
||||
private static readonly string moneyId = "543be5dd4bdc2deb348b4569";
|
||||
private static readonly string armorPlate = "644120aa86ffbe10ee032b6f";
|
||||
private static readonly string builtInInserts = "65649eb40bf0ed77b8044453";
|
||||
private static readonly List<string> nonFiRItems = new List<string>() { magazineId, drugId, mediKitItem, medicalItemId, injectorItemId, throwableItemId, ammoItemId, armorPlate, builtInInserts };
|
||||
@ -32,7 +33,7 @@ namespace Aki.Custom.CustomAI
|
||||
private static readonly string knifeId = "5447e1d04bdc2dff2f8b4567";
|
||||
|
||||
private static readonly List<string> weaponTypeIds = new List<string>() { pistolId, smgId, assaultRifleId, assaultCarbineId, shotgunId, marksmanRifleId, sniperRifleId, machinegunId, grenadeLauncherId, knifeId };
|
||||
private static readonly List<string> nonFiRPocketLoot = new List<string>{ throwableItemId, ammoItemId, magazineId, medicalItemId, mediKitItem, injectorItemId, drugId };
|
||||
private static readonly List<string> nonFiRPocketLoot = new List<string>{ moneyId, throwableItemId, ammoItemId, magazineId, medicalItemId, mediKitItem, injectorItemId, drugId };
|
||||
private readonly ManualLogSource logger;
|
||||
|
||||
public PmcFoundInRaidEquipment(ManualLogSource logger)
|
||||
|
@ -16,7 +16,7 @@ namespace Aki.Custom.Patches
|
||||
[PatchPrefix]
|
||||
private static void PatchPreFix(ref Vector3 velocity)
|
||||
{
|
||||
velocity.y = Mathf.Clamp(velocity.y, -1f, 1f);
|
||||
velocity.y = Mathf.Clamp(velocity.y, -2f, 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BepInEx.Logging;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace Aki.PrePatch
|
||||
@ -10,8 +14,12 @@ namespace Aki.PrePatch
|
||||
public static int sptUsecValue = 47;
|
||||
public static int sptBearValue = 48;
|
||||
|
||||
private static string _sptPluginFolder = "plugins/spt";
|
||||
|
||||
public static void Patch(ref AssemblyDefinition assembly)
|
||||
{
|
||||
PerformPreValidation();
|
||||
|
||||
var botEnums = assembly.MainModule.GetType("EFT.WildSpawnType");
|
||||
|
||||
var sptUsec = new FieldDefinition("sptUsec",
|
||||
@ -27,5 +35,72 @@ namespace Aki.PrePatch
|
||||
botEnums.Fields.Add(sptUsec);
|
||||
botEnums.Fields.Add(sptBear);
|
||||
}
|
||||
|
||||
private static void PerformPreValidation()
|
||||
{
|
||||
// Check if the launcher was used
|
||||
bool launcherUsed = ValidateLauncherUse(out string launcherError);
|
||||
|
||||
// Check that all the expected plugins are in the BepInEx/Plugins/spt/ folder
|
||||
string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
string sptPluginPath = Path.GetFullPath(Path.Combine(assemblyFolder, "..", _sptPluginFolder));
|
||||
bool pluginsValidated = ValidateSptPlugins(sptPluginPath, out string pluginErrorMessage);
|
||||
|
||||
// If either the launcher wasn't used, or the plugins weren't found, exit
|
||||
if (!launcherUsed || !pluginsValidated)
|
||||
{
|
||||
string errorTitle = (!launcherUsed) ? "Startup Error" : "Missing Core Files";
|
||||
string errorMessage = (!launcherUsed) ? launcherError : pluginErrorMessage;
|
||||
MessageBoxHelper.Show(errorMessage, $"[SPT-AKI] {errorTitle}", MessageBoxHelper.MessageBoxType.OK);
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ValidateLauncherUse(out string message)
|
||||
{
|
||||
// Validate that parameters were passed to EscapeFromTarkov.exe, to verify the
|
||||
// player used the SPT Launcher to start the process
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
message = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
message = "Please start SPT-AKI using Aki.Launcher.exe. Exiting.";
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool ValidateSptPlugins(string sptPluginPath, out string message)
|
||||
{
|
||||
string exitMessage = "\n\nPlease re-install SPT. Exiting.";
|
||||
ManualLogSource logger = Logger.CreateLogSource(nameof(AkiBotsPrePatcher));
|
||||
|
||||
// Validate that the SPT plugin path exists
|
||||
if (!Directory.Exists(sptPluginPath))
|
||||
{
|
||||
message = $"'{sptPluginPath}' directory not found{exitMessage}";
|
||||
logger.LogError(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate that the folder exists, and contains our plugins
|
||||
string[] sptPlugins = new string[] { "aki-core.dll", "aki-custom.dll", "aki-singleplayer.dll" };
|
||||
string[] foundPlugins = Directory.GetFiles(sptPluginPath).Select(x => Path.GetFileName(x)).ToArray();
|
||||
|
||||
foreach (string plugin in sptPlugins)
|
||||
{
|
||||
if (!foundPlugins.Contains(plugin))
|
||||
{
|
||||
message = $"Required SPT plugins missing from '{sptPluginPath}'{exitMessage}";
|
||||
logger.LogError(message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
message = "";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
56
project/Aki.PrePatch/MessageBoxHelper.cs
Normal file
56
project/Aki.PrePatch/MessageBoxHelper.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Aki.PrePatch
|
||||
{
|
||||
internal class MessageBoxHelper
|
||||
{
|
||||
public enum MessageBoxType : uint
|
||||
{
|
||||
ABORTRETRYIGNORE = (uint)(0x00000002L | 0x00000010L),
|
||||
CANCELTRYCONTINUE = (uint)(0x00000006L | 0x00000030L),
|
||||
HELP = (uint)(0x00004000L | 0x00000040L),
|
||||
OK = (uint)(0x00000000L | 0x00000040L),
|
||||
OKCANCEL = (uint)(0x00000001L | 0x00000040L),
|
||||
RETRYCANCEL = (uint)0x00000005L,
|
||||
YESNO = (uint)(0x00000004L | 0x00000040L),
|
||||
YESNOCANCEL = (uint)(0x00000003L | 0x00000040L),
|
||||
DEFAULT = (uint)(0x00000000L | 0x00000010L)
|
||||
}
|
||||
|
||||
public enum MessageBoxResult
|
||||
{
|
||||
ERROR = -1,
|
||||
OK = 1,
|
||||
CANCEL = 2,
|
||||
ABORT = 3,
|
||||
RETRY = 4,
|
||||
IGNORE = 5,
|
||||
YES = 6,
|
||||
NO = 7,
|
||||
TRY_AGAIN = 10
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetActiveWindow();
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern int MessageBox(IntPtr hwnd, String lpText, String lpCaption, uint uType);
|
||||
|
||||
public static IntPtr GetWindowHandle()
|
||||
{
|
||||
return GetActiveWindow();
|
||||
}
|
||||
|
||||
public static MessageBoxResult Show(string text, string caption, MessageBoxType type = MessageBoxType.DEFAULT)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (MessageBoxResult)MessageBox(GetWindowHandle(), text, caption, (uint)type); ;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return MessageBoxResult.ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user