0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-12 22:30:44 -05:00

Updated to support

One error left that prevents build: LighthouseProgressionClass.cs
This commit is contained in:
Dev 2023-07-07 10:37:47 +01:00
parent a62df7c9be
commit 181f2328a5
11 changed files with 72 additions and 58 deletions

View File

@ -34,7 +34,7 @@ namespace Aki.Core.Patches
} }
[PatchPrefix] [PatchPrefix]
private static bool PatchPrefix(ref GStruct22 legacyParams) private static bool PatchPrefix(ref GStruct21 legacyParams)
{ {
//Console.WriteLine($"Original url {legacyParams.Url}"); //Console.WriteLine($"Original url {legacyParams.Url}");
legacyParams.Url = legacyParams.Url legacyParams.Url = legacyParams.Url

View File

@ -27,52 +27,57 @@ namespace Aki.Custom.Airdrops.Utils
return 100; return 100;
} }
string location = gameWorld.RegisteredPlayers[0].Location; // Get players current location
string playerLocation = gameWorld.MainPlayer.Location;
int result = 25; int result = 0;
switch (location.ToLower()) switch (playerLocation.ToLower())
{ {
case "bigmap": case "bigmap":
{ {
result = config.AirdropChancePercent.Bigmap; result = config.AirdropChancePercent.Bigmap;
break; break;
} }
case "interchange": case "interchange":
{ {
result = config.AirdropChancePercent.Interchange; result = config.AirdropChancePercent.Interchange;
break; break;
} }
case "rezervbase": case "rezervbase":
{ {
result = config.AirdropChancePercent.Reserve; result = config.AirdropChancePercent.Reserve;
break; break;
} }
case "shoreline": case "shoreline":
{ {
result = config.AirdropChancePercent.Shoreline; result = config.AirdropChancePercent.Shoreline;
break; break;
} }
case "woods": case "woods":
{ {
result = config.AirdropChancePercent.Woods; result = config.AirdropChancePercent.Woods;
break; break;
} }
case "lighthouse": case "lighthouse":
{ {
result = config.AirdropChancePercent.Lighthouse; result = config.AirdropChancePercent.Lighthouse;
break; break;
} }
case "tarkovstreets": 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; break;
}
} }
return result; return result;
} }
public static bool ShouldAirdropOccur(int dropChance, List<AirdropPoint> airdropPoints) private static bool ShouldAirdropOccur(int dropChance, List<AirdropPoint> airdropPoints)
{ {
return airdropPoints.Count > 0 && Random.Range(0, 100) <= dropChance; return airdropPoints.Count > 0 && Random.Range(0, 100) <= dropChance;
} }
@ -81,15 +86,16 @@ namespace Aki.Custom.Airdrops.Utils
{ {
var serverConfig = GetConfigFromServer(); var serverConfig = GetConfigFromServer();
var allAirdropPoints = LocationScene.GetAll<AirdropPoint>().ToList(); var allAirdropPoints = LocationScene.GetAll<AirdropPoint>().ToList();
var playerPosition = gameWorld.RegisteredPlayers[0].Position; var playerPosition = gameWorld.MainPlayer.Position;
var flareAirdropPoints = new List<AirdropPoint>(); var flareAirdropPoints = new List<AirdropPoint>();
var dropChance = ChanceToSpawn(gameWorld, serverConfig, isFlare); var dropChance = ChanceToSpawn(gameWorld, serverConfig, isFlare);
var flareSpawnRadiusDistance = 100f;
if (isFlare && allAirdropPoints.Count > 0) if (isFlare && allAirdropPoints.Count > 0)
{ {
foreach (AirdropPoint point in allAirdropPoints) foreach (AirdropPoint point in allAirdropPoints)
{ {
if (Vector3.Distance(playerPosition, point.transform.position) <= 100f) if (Vector3.Distance(playerPosition, point.transform.position) <= flareSpawnRadiusDistance)
{ {
flareAirdropPoints.Add(point); flareAirdropPoints.Add(point);
} }
@ -98,7 +104,7 @@ namespace Aki.Custom.Airdrops.Utils
if (flareAirdropPoints.Count == 0 && isFlare) 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()); flareAirdropPoints.Add(allAirdropPoints.OrderBy(_ => Guid.NewGuid()).FirstOrDefault());
} }

View File

@ -98,7 +98,7 @@ namespace Aki.Custom.Patches
{ {
var gameWorld = Singleton<GameWorld>.Instance; var gameWorld = Singleton<GameWorld>.Instance;
return gameWorld.RegisteredPlayers[0].Location; return gameWorld.MainPlayer.Location;
} }
private static bool CacheIsStale() private static bool CacheIsStale()

View File

@ -33,7 +33,7 @@ namespace Aki.Custom.Patches
var player = Singleton<GameWorld>.Instance.MainPlayer; var player = Singleton<GameWorld>.Instance.MainPlayer;
if (profileId == player?.Profile.Id) if (profileId == player?.Profile.Id)
{ {
GClass2731.Instance.CloseAllScreensForced(); GClass2974.Instance.CloseAllScreensForced();
} }
return true; return true;

View File

@ -29,7 +29,6 @@ namespace Aki.Custom.Patches
var raidSettings = Traverse.Create(controller).Field<RaidSettings>("RaidSettings").Value; var raidSettings = Traverse.Create(controller).Field<RaidSettings>("RaidSettings").Value;
raidSettings.RaidMode = ERaidMode.Local; raidSettings.RaidMode = ERaidMode.Local;
raidSettings.BotSettings.IsEnabled = true;
// Default checkbox to be ticked // Default checkbox to be ticked
____offlineModeToggle.isOn = true; ____offlineModeToggle.isOn = true;

View File

@ -14,7 +14,7 @@ namespace Aki.SinglePlayer.Models.Progression
private bool _addedToEnemy; private bool _addedToEnemy;
private List<MineDirectionalColliders> _mines; private List<MineDirectionalColliders> _mines;
private RecodableItemClass _transmitter; private RecodableItemClass _transmitter;
private List<Player> _bosses; private List<IAIDetails> _bosses;
private bool _aggressor; private bool _aggressor;
private bool _disabledDoor; private bool _disabledDoor;
private readonly string _transmitterId = "62e910aaf957f2915e0a5e36"; private readonly string _transmitterId = "62e910aaf957f2915e0a5e36";
@ -22,10 +22,13 @@ namespace Aki.SinglePlayer.Models.Progression
public void Start() public void Start()
{ {
_gameWorld = Singleton<GameWorld>.Instance; _gameWorld = Singleton<GameWorld>.Instance;
_bosses = new List<Player>(); _bosses = new List<IAIDetails>();
_mines = GameObject.FindObjectsOfType<MineDirectionalColliders>().ToList(); _mines = GameObject.FindObjectsOfType<MineDirectionalColliders>().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 player is a scav, there is no need to continue this method.
if (_gameWorld.MainPlayer.Side == EPlayerSide.Savage) if (_gameWorld.MainPlayer.Side == EPlayerSide.Savage)
@ -55,7 +58,10 @@ namespace Aki.SinglePlayer.Models.Progression
_timer += Time.deltaTime; _timer += Time.deltaTime;
if (_timer < 10f) return; if (_timer < 10f)
{
return;
}
if (_bosses.Count == 0) if (_bosses.Count == 0)
{ {
@ -100,22 +106,23 @@ namespace Aki.SinglePlayer.Models.Progression
private void SetupBosses() 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 // Subscribe to Bosses OnDeath event
player.OnPlayerDeadOrUnspawn += player1 => aiBot.OnIPlayerDeadOrUnspawn += player1 =>
{ {
if (player1.KillerId != null && player1.KillerId == _gameWorld.MainPlayer.ProfileId) if (player1?.Profile.KillerId == _gameWorld.MainPlayer.ProfileId)
{ {
_aggressor = true; _aggressor = true;
} }
}; };
_bosses.Add(player); _bosses.Add(aiBot);
} }
} }
} }

View File

@ -2,7 +2,7 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Reflection; using System.Reflection;
using TraderInfo = EFT.Profile.GClass1666; using TraderInfo = EFT.Profile.GClass1726;
namespace Aki.SinglePlayer.Patches.RaidFix namespace Aki.SinglePlayer.Patches.RaidFix
{ {

View File

@ -21,7 +21,7 @@ namespace Aki.SinglePlayer.Patches.RaidFix
.GetMethod("FindActiveEffect", BindingFlags.Instance | BindingFlags.Public) .GetMethod("FindActiveEffect", BindingFlags.Instance | BindingFlags.Public)
.MakeGenericMethod(typeof(ActiveHealthControllerClass) .MakeGenericMethod(typeof(ActiveHealthControllerClass)
.GetNestedType("Stun", BindingFlags.Instance | BindingFlags.NonPublic)) .GetNestedType("Stun", BindingFlags.Instance | BindingFlags.NonPublic))
.Invoke(Singleton<GameWorld>.Instance.AllPlayers[0].ActiveHealthController, new object[] { EBodyPart.Common }) != null; .Invoke(Singleton<GameWorld>.Instance.MainPlayer.ActiveHealthController, new object[] { EBodyPart.Common }) != null;
return shouldInvoke; return shouldInvoke;
} }

View File

@ -32,8 +32,7 @@ namespace Aki.SinglePlayer.Patches.ScavMode
Logger.LogError("Unable to Find Gameworld or RegisterPlayers... Unable to Disable Extracts for Scav raid"); 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.MainPlayer;
Player player = gameWorld.RegisteredPlayers.Find(p => p.IsYourPlayer);
var exfilController = gameWorld.ExfiltrationController; var exfilController = gameWorld.ExfiltrationController;

View File

@ -111,13 +111,16 @@ namespace Aki.SinglePlayer.Patches.ScavMode
{ {
var profile = PatchConstants.BackEndSession.Profile; var profile = PatchConstants.BackEndSession.Profile;
var menuController = (object)GetMenuController(); var menuController = (object)GetMenuController();
// Get fields from MainMenuController.cs
var raidSettings = Traverse.Create(menuController).Field("raidSettings_0").GetValue<RaidSettings>(); var raidSettings = Traverse.Create(menuController).Field("raidSettings_0").GetValue<RaidSettings>();
var matchmakerPlayersController = Traverse.Create(menuController).Field("gclass2784_0").GetValue<GClass2784>(); var matchmakerPlayersController = Traverse.Create(menuController).Field("gclass3027_0").GetValue<GClass3027>();
var gclass = new MatchmakerOfflineRaidScreen.GClass2773(profile?.Info, ref raidSettings, matchmakerPlayersController);
var gclass = new MatchmakerOfflineRaidScreen.GClass3016(profile?.Info, ref raidSettings, matchmakerPlayersController);
gclass.OnShowNextScreen += LoadOfflineRaidNextScreen; gclass.OnShowNextScreen += LoadOfflineRaidNextScreen;
// ready method // Ready method
gclass.OnShowReadyScreen += (OfflineRaidAction)Delegate.CreateDelegate(typeof(OfflineRaidAction), menuController, "method_67"); gclass.OnShowReadyScreen += (OfflineRaidAction)Delegate.CreateDelegate(typeof(OfflineRaidAction), menuController, "method_67");
gclass.ShowScreen(EScreenState.Queued); gclass.ShowScreen(EScreenState.Queued);
} }
@ -132,10 +135,10 @@ namespace Aki.SinglePlayer.Patches.ScavMode
raidSettings.WavesSettings.IsBosses = true; raidSettings.WavesSettings.IsBosses = true;
} }
// set offline raid values // Set offline raid values
_isLocalField.SetValue(menuController, raidSettings.Local); _isLocalField.SetValue(menuController, raidSettings.Local);
// load ready screen method // Load ready screen method
_onReadyScreenMethod.Invoke(menuController, null); _onReadyScreenMethod.Invoke(menuController, null);
} }

Binary file not shown.