diff --git a/project/Aki.Core/Patches/TransportPrefixPatch.cs b/project/Aki.Core/Patches/TransportPrefixPatch.cs index 0f83261..b784d09 100644 --- a/project/Aki.Core/Patches/TransportPrefixPatch.cs +++ b/project/Aki.Core/Patches/TransportPrefixPatch.cs @@ -34,7 +34,7 @@ namespace Aki.Core.Patches } [PatchPrefix] - private static bool PatchPrefix(ref GStruct22 legacyParams) + private static bool PatchPrefix(ref GStruct21 legacyParams) { //Console.WriteLine($"Original url {legacyParams.Url}"); legacyParams.Url = legacyParams.Url diff --git a/project/Aki.Custom/Airdrops/Utils/AirdropUtil.cs b/project/Aki.Custom/Airdrops/Utils/AirdropUtil.cs index fbe3e98..4efc73b 100644 --- a/project/Aki.Custom/Airdrops/Utils/AirdropUtil.cs +++ b/project/Aki.Custom/Airdrops/Utils/AirdropUtil.cs @@ -27,52 +27,57 @@ namespace Aki.Custom.Airdrops.Utils return 100; } - string location = gameWorld.RegisteredPlayers[0].Location; + // Get players current location + string playerLocation = gameWorld.MainPlayer.Location; - int result = 25; - switch (location.ToLower()) + int result = 0; + switch (playerLocation.ToLower()) { case "bigmap": - { - result = config.AirdropChancePercent.Bigmap; - break; - } + { + result = config.AirdropChancePercent.Bigmap; + break; + } case "interchange": - { - result = config.AirdropChancePercent.Interchange; - break; - } + { + result = config.AirdropChancePercent.Interchange; + break; + } case "rezervbase": - { - result = config.AirdropChancePercent.Reserve; - break; - } + { + result = config.AirdropChancePercent.Reserve; + break; + } case "shoreline": - { - result = config.AirdropChancePercent.Shoreline; - break; - } + { + result = config.AirdropChancePercent.Shoreline; + break; + } case "woods": - { - result = config.AirdropChancePercent.Woods; - break; - } + { + result = config.AirdropChancePercent.Woods; + break; + } case "lighthouse": - { - result = config.AirdropChancePercent.Lighthouse; - break; - } + { + result = config.AirdropChancePercent.Lighthouse; + break; + } case "tarkovstreets": - { - result = config.AirdropChancePercent.TarkovStreets; + { + result = config.AirdropChancePercent.TarkovStreets; + break; + } + default: + Debug.LogError($"[AKI-AIRDROPS]: Map with name {playerLocation} not handled, defaulting spawn chance to 25%"); + result = 25; break; - } } return result; } - public static bool ShouldAirdropOccur(int dropChance, List airdropPoints) + private static bool ShouldAirdropOccur(int dropChance, List airdropPoints) { return airdropPoints.Count > 0 && Random.Range(0, 100) <= dropChance; } @@ -81,15 +86,16 @@ namespace Aki.Custom.Airdrops.Utils { var serverConfig = GetConfigFromServer(); var allAirdropPoints = LocationScene.GetAll().ToList(); - var playerPosition = gameWorld.RegisteredPlayers[0].Position; + var playerPosition = gameWorld.MainPlayer.Position; var flareAirdropPoints = new List(); var dropChance = ChanceToSpawn(gameWorld, serverConfig, isFlare); + var flareSpawnRadiusDistance = 100f; if (isFlare && allAirdropPoints.Count > 0) { foreach (AirdropPoint point in allAirdropPoints) { - if (Vector3.Distance(playerPosition, point.transform.position) <= 100f) + if (Vector3.Distance(playerPosition, point.transform.position) <= flareSpawnRadiusDistance) { flareAirdropPoints.Add(point); } @@ -98,7 +104,7 @@ namespace Aki.Custom.Airdrops.Utils if (flareAirdropPoints.Count == 0 && isFlare) { - Debug.LogError($"[AKI-AIRDROPS]: Airdrop called in by flare, Unable to find an airdropPoint within 100m, defaulting to normal drop"); + Debug.LogError($"[AKI-AIRDROPS]: Airdrop called in by flare, Unable to find an airdropPoint within {flareSpawnRadiusDistance}m, defaulting to normal drop"); flareAirdropPoints.Add(allAirdropPoints.OrderBy(_ => Guid.NewGuid()).FirstOrDefault()); } diff --git a/project/Aki.Custom/Patches/CustomAiPatch.cs b/project/Aki.Custom/Patches/CustomAiPatch.cs index 29d1b89..b6aba2c 100644 --- a/project/Aki.Custom/Patches/CustomAiPatch.cs +++ b/project/Aki.Custom/Patches/CustomAiPatch.cs @@ -98,7 +98,7 @@ namespace Aki.Custom.Patches { var gameWorld = Singleton.Instance; - return gameWorld.RegisteredPlayers[0].Location; + return gameWorld.MainPlayer.Location; } private static bool CacheIsStale() diff --git a/project/Aki.Custom/Patches/ExitWhileLootingPatch.cs b/project/Aki.Custom/Patches/ExitWhileLootingPatch.cs index 12bd3e0..7f82558 100644 --- a/project/Aki.Custom/Patches/ExitWhileLootingPatch.cs +++ b/project/Aki.Custom/Patches/ExitWhileLootingPatch.cs @@ -33,7 +33,7 @@ namespace Aki.Custom.Patches var player = Singleton.Instance.MainPlayer; if (profileId == player?.Profile.Id) { - GClass2731.Instance.CloseAllScreensForced(); + GClass2974.Instance.CloseAllScreensForced(); } return true; diff --git a/project/Aki.Custom/Patches/OfflineRaidMenuPatch.cs b/project/Aki.Custom/Patches/OfflineRaidMenuPatch.cs index 80b5cd0..047a692 100644 --- a/project/Aki.Custom/Patches/OfflineRaidMenuPatch.cs +++ b/project/Aki.Custom/Patches/OfflineRaidMenuPatch.cs @@ -29,7 +29,6 @@ namespace Aki.Custom.Patches var raidSettings = Traverse.Create(controller).Field("RaidSettings").Value; raidSettings.RaidMode = ERaidMode.Local; - raidSettings.BotSettings.IsEnabled = true; // Default checkbox to be ticked ____offlineModeToggle.isOn = true; diff --git a/project/Aki.SinglePlayer/Models/Progression/LighthouseProgressionClass.cs b/project/Aki.SinglePlayer/Models/Progression/LighthouseProgressionClass.cs index 58a791a..21e0768 100644 --- a/project/Aki.SinglePlayer/Models/Progression/LighthouseProgressionClass.cs +++ b/project/Aki.SinglePlayer/Models/Progression/LighthouseProgressionClass.cs @@ -14,7 +14,7 @@ namespace Aki.SinglePlayer.Models.Progression private bool _addedToEnemy; private List _mines; private RecodableItemClass _transmitter; - private List _bosses; + private List _bosses; private bool _aggressor; private bool _disabledDoor; private readonly string _transmitterId = "62e910aaf957f2915e0a5e36"; @@ -22,10 +22,13 @@ namespace Aki.SinglePlayer.Models.Progression public void Start() { _gameWorld = Singleton.Instance; - _bosses = new List(); + _bosses = new List(); _mines = GameObject.FindObjectsOfType().ToList(); - if (_gameWorld == null || _gameWorld.MainPlayer.Location.ToLower() != "lighthouse") return; + if (_gameWorld == null || !string.Equals(_gameWorld.MainPlayer.Location, "lighthouse", System.StringComparison.OrdinalIgnoreCase)) + { + return; + } // if player is a scav, there is no need to continue this method. if (_gameWorld.MainPlayer.Side == EPlayerSide.Savage) @@ -55,7 +58,10 @@ namespace Aki.SinglePlayer.Models.Progression _timer += Time.deltaTime; - if (_timer < 10f) return; + if (_timer < 10f) + { + return; + } if (_bosses.Count == 0) { @@ -100,22 +106,23 @@ namespace Aki.SinglePlayer.Models.Progression private void SetupBosses() { - foreach (var player in _gameWorld.AllPlayers) + foreach (var aiBot in _gameWorld.RegisteredPlayers) { - if (!player.IsYourPlayer) + if (!aiBot.IsYourPlayer) { - if (player.AIData.BotOwner.IsRole(WildSpawnType.bossZryachiy) || player.AIData.BotOwner.IsRole(WildSpawnType.followerZryachiy)) + // Edge case of bossZryachiy not being hostile to player + if (aiBot.AIData.BotOwner.IsRole(WildSpawnType.bossZryachiy) || aiBot.AIData.BotOwner.IsRole(WildSpawnType.followerZryachiy)) { - // Sub to Bosses OnDeath event, Set mainplayer to aggressor on this script - player.OnPlayerDeadOrUnspawn += player1 => + // Subscribe to Bosses OnDeath event + aiBot.OnIPlayerDeadOrUnspawn += player1 => { - if (player1.KillerId != null && player1.KillerId == _gameWorld.MainPlayer.ProfileId) + if (player1?.Profile.KillerId == _gameWorld.MainPlayer.ProfileId) { _aggressor = true; } }; - _bosses.Add(player); + _bosses.Add(aiBot); } } } diff --git a/project/Aki.SinglePlayer/Patches/RaidFix/PostRaidHealingPricePatch.cs b/project/Aki.SinglePlayer/Patches/RaidFix/PostRaidHealingPricePatch.cs index 26eeaa6..1e377c0 100644 --- a/project/Aki.SinglePlayer/Patches/RaidFix/PostRaidHealingPricePatch.cs +++ b/project/Aki.SinglePlayer/Patches/RaidFix/PostRaidHealingPricePatch.cs @@ -2,7 +2,7 @@ using HarmonyLib; using System; using System.Reflection; -using TraderInfo = EFT.Profile.GClass1666; +using TraderInfo = EFT.Profile.GClass1726; namespace Aki.SinglePlayer.Patches.RaidFix { diff --git a/project/Aki.SinglePlayer/Patches/RaidFix/TinnitusFixPatch.cs b/project/Aki.SinglePlayer/Patches/RaidFix/TinnitusFixPatch.cs index 79e83b8..96141a5 100644 --- a/project/Aki.SinglePlayer/Patches/RaidFix/TinnitusFixPatch.cs +++ b/project/Aki.SinglePlayer/Patches/RaidFix/TinnitusFixPatch.cs @@ -21,7 +21,7 @@ namespace Aki.SinglePlayer.Patches.RaidFix .GetMethod("FindActiveEffect", BindingFlags.Instance | BindingFlags.Public) .MakeGenericMethod(typeof(ActiveHealthControllerClass) .GetNestedType("Stun", BindingFlags.Instance | BindingFlags.NonPublic)) - .Invoke(Singleton.Instance.AllPlayers[0].ActiveHealthController, new object[] { EBodyPart.Common }) != null; + .Invoke(Singleton.Instance.MainPlayer.ActiveHealthController, new object[] { EBodyPart.Common }) != null; return shouldInvoke; } diff --git a/project/Aki.SinglePlayer/Patches/ScavMode/ExfilPointManagerPatch.cs b/project/Aki.SinglePlayer/Patches/ScavMode/ExfilPointManagerPatch.cs index 2ab15f1..4dc694c 100644 --- a/project/Aki.SinglePlayer/Patches/ScavMode/ExfilPointManagerPatch.cs +++ b/project/Aki.SinglePlayer/Patches/ScavMode/ExfilPointManagerPatch.cs @@ -32,8 +32,7 @@ namespace Aki.SinglePlayer.Patches.ScavMode Logger.LogError("Unable to Find Gameworld or RegisterPlayers... Unable to Disable Extracts for Scav raid"); } - // One of the RegisteredPlayers will have the IsYourPlayer flag set, which will be our own Player instance. - Player player = gameWorld.RegisteredPlayers.Find(p => p.IsYourPlayer); + Player player = gameWorld.MainPlayer; var exfilController = gameWorld.ExfiltrationController; diff --git a/project/Aki.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs b/project/Aki.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs index cc6178d..0c32402 100644 --- a/project/Aki.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs +++ b/project/Aki.SinglePlayer/Patches/ScavMode/LoadOfflineRaidScreenPatch.cs @@ -111,13 +111,16 @@ namespace Aki.SinglePlayer.Patches.ScavMode { var profile = PatchConstants.BackEndSession.Profile; var menuController = (object)GetMenuController(); + + // Get fields from MainMenuController.cs var raidSettings = Traverse.Create(menuController).Field("raidSettings_0").GetValue(); - var matchmakerPlayersController = Traverse.Create(menuController).Field("gclass2784_0").GetValue(); - var gclass = new MatchmakerOfflineRaidScreen.GClass2773(profile?.Info, ref raidSettings, matchmakerPlayersController); + var matchmakerPlayersController = Traverse.Create(menuController).Field("gclass3027_0").GetValue(); + + var gclass = new MatchmakerOfflineRaidScreen.GClass3016(profile?.Info, ref raidSettings, matchmakerPlayersController); gclass.OnShowNextScreen += LoadOfflineRaidNextScreen; - // ready method + // Ready method gclass.OnShowReadyScreen += (OfflineRaidAction)Delegate.CreateDelegate(typeof(OfflineRaidAction), menuController, "method_67"); gclass.ShowScreen(EScreenState.Queued); } @@ -132,10 +135,10 @@ namespace Aki.SinglePlayer.Patches.ScavMode raidSettings.WavesSettings.IsBosses = true; } - // set offline raid values + // Set offline raid values _isLocalField.SetValue(menuController, raidSettings.Local); - // load ready screen method + // Load ready screen method _onReadyScreenMethod.Invoke(menuController, null); } diff --git a/project/Shared/Hollowed/hollowed.dll b/project/Shared/Hollowed/hollowed.dll index 71ef57a..8b9cc9f 100644 Binary files a/project/Shared/Hollowed/hollowed.dll and b/project/Shared/Hollowed/hollowed.dll differ