0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-12 17:30:43 -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]
private static bool PatchPrefix(ref GStruct22 legacyParams)
private static bool PatchPrefix(ref GStruct21 legacyParams)
{
//Console.WriteLine($"Original url {legacyParams.Url}");
legacyParams.Url = legacyParams.Url

View File

@ -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<AirdropPoint> airdropPoints)
private static bool ShouldAirdropOccur(int dropChance, List<AirdropPoint> 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<AirdropPoint>().ToList();
var playerPosition = gameWorld.RegisteredPlayers[0].Position;
var playerPosition = gameWorld.MainPlayer.Position;
var flareAirdropPoints = new List<AirdropPoint>();
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());
}

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ namespace Aki.SinglePlayer.Models.Progression
private bool _addedToEnemy;
private List<MineDirectionalColliders> _mines;
private RecodableItemClass _transmitter;
private List<Player> _bosses;
private List<IAIDetails> _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<GameWorld>.Instance;
_bosses = new List<Player>();
_bosses = new List<IAIDetails>();
_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 (_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);
}
}
}

View File

@ -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
{

View File

@ -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<GameWorld>.Instance.AllPlayers[0].ActiveHealthController, new object[] { EBodyPart.Common }) != null;
.Invoke(Singleton<GameWorld>.Instance.MainPlayer.ActiveHealthController, new object[] { EBodyPart.Common }) != null;
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");
}
// 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;

View File

@ -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<RaidSettings>();
var matchmakerPlayersController = Traverse.Create(menuController).Field("gclass2784_0").GetValue<GClass2784>();
var gclass = new MatchmakerOfflineRaidScreen.GClass2773(profile?.Info, ref raidSettings, matchmakerPlayersController);
var matchmakerPlayersController = Traverse.Create(menuController).Field("gclass3027_0").GetValue<GClass3027>();
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);
}

Binary file not shown.