mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 06:10:45 -05:00
Delayed spawning BTR bot to GameWorld.OnGameStarted (!69)
Honestly this is just a shot in the dark hotfix. I've tested it and these changes still work fine for me. Let me know if this fixes the BTR not working, Chomp Reviewed-on: SPT-AKI/Modules#69 Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com> Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
a124ace054
commit
a48e40b481
@ -61,9 +61,10 @@ namespace Aki.Custom
|
|||||||
new BTRTurretDefaultAimingPositionPatch().Enable();
|
new BTRTurretDefaultAimingPositionPatch().Enable();
|
||||||
new BTRIsDoorsClosedPath().Enable();
|
new BTRIsDoorsClosedPath().Enable();
|
||||||
new BTRPatch().Enable();
|
new BTRPatch().Enable();
|
||||||
|
new BTRSpawnBotAtRaidStartPatch().Enable();
|
||||||
new BTRTransferItemsPatch().Enable();
|
new BTRTransferItemsPatch().Enable();
|
||||||
new BTREndRaidItemDeliveryPatch().Enable();
|
new BTREndRaidItemDeliveryPatch().Enable();
|
||||||
new BTRBaseLocalGameStopPatch().Enable();
|
new BTRDestroyAtRaidEndPatch().Enable();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -161,7 +161,6 @@ namespace Aki.Custom.BTR
|
|||||||
var botsController = Singleton<IBotGame>.Instance.BotsController;
|
var botsController = Singleton<IBotGame>.Instance.BotsController;
|
||||||
btrBotService = botsController.BotTradersServices.BTRServices;
|
btrBotService = botsController.BotTradersServices.BTRServices;
|
||||||
btrController.method_3(); // spawns server-side BTR game object
|
btrController.method_3(); // spawns server-side BTR game object
|
||||||
botsController.BotSpawner.SpawnBotBTR(); // spawns the scav bot which controls the BTR's turret
|
|
||||||
|
|
||||||
// Initial BTR configuration
|
// Initial BTR configuration
|
||||||
btrServerSide = btrController.BtrVehicle;
|
btrServerSide = btrController.BtrVehicle;
|
||||||
|
@ -25,20 +25,24 @@ namespace Aki.Custom.BTR.Patches
|
|||||||
return AccessTools.Method(typeof(BTRTurretView), nameof(BTRTurretView.method_1));
|
return AccessTools.Method(typeof(BTRTurretView), nameof(BTRTurretView.method_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPrefix]
|
||||||
private static void PatchPostfix(BTRTurretView __instance, int btrBotId, ref bool __result)
|
private static bool PatchPrefix(BTRTurretView __instance, int btrBotId, ref bool __result)
|
||||||
{
|
{
|
||||||
var gameWorld = Singleton<GameWorld>.Instance;
|
var gameWorld = Singleton<GameWorld>.Instance;
|
||||||
if (gameWorld == null)
|
if (gameWorld == null)
|
||||||
{
|
{
|
||||||
Logger.LogError("[AKI-BTR] BTRBotInitPatch - GameWorld is null");
|
Logger.LogError("[AKI-BTR] BTRBotInitPatch - GameWorld is null");
|
||||||
return;
|
__result = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var alivePlayersList = gameWorld.AllAlivePlayersList;
|
var alivePlayersList = gameWorld.AllAlivePlayersList;
|
||||||
bool doesBtrBotExist = alivePlayersList.Exists(x => x.Id == btrBotId);
|
bool doesBtrBotExist = alivePlayersList.Exists(x => x.Id == btrBotId);
|
||||||
if (doesBtrBotExist)
|
if (!doesBtrBotExist)
|
||||||
{
|
{
|
||||||
|
__result = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Player player = alivePlayersList.First(x => x.Id == btrBotId);
|
Player player = alivePlayersList.First(x => x.Id == btrBotId);
|
||||||
@ -76,6 +80,7 @@ namespace Aki.Custom.BTR.Patches
|
|||||||
btrTurretViewTupleField.SetValue(__instance, tuple);
|
btrTurretViewTupleField.SetValue(__instance, tuple);
|
||||||
|
|
||||||
__result = true;
|
__result = true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -84,5 +89,4 @@ namespace Aki.Custom.BTR.Patches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using Object = UnityEngine.Object;
|
|||||||
|
|
||||||
namespace Aki.Custom.BTR.Patches
|
namespace Aki.Custom.BTR.Patches
|
||||||
{
|
{
|
||||||
public class BTRBaseLocalGameStopPatch : ModulePatch
|
public class BTRDestroyAtRaidEndPatch : ModulePatch
|
||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
@ -26,7 +26,7 @@ namespace Aki.Custom.BTR.Patches
|
|||||||
var btrManager = gameWorld.GetComponent<BTRManager>();
|
var btrManager = gameWorld.GetComponent<BTRManager>();
|
||||||
if (btrManager != null)
|
if (btrManager != null)
|
||||||
{
|
{
|
||||||
Logger.LogWarning("[AKI-BTR] BTRBaseLocalGameStopPatch - Raid Ended: Destroying BTRManager");
|
Logger.LogWarning("[AKI-BTR] BTRDestroyAtRaidEndPatch - Raid Ended: Destroying BTRManager");
|
||||||
Object.Destroy(btrManager);
|
Object.Destroy(btrManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
using Aki.Reflection.Patching;
|
||||||
|
using Comfort.Common;
|
||||||
|
using EFT;
|
||||||
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Aki.Custom.BTR.Patches
|
||||||
|
{
|
||||||
|
public class BTRSpawnBotAtRaidStartPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
private static void PatchPostfix(GameWorld __instance)
|
||||||
|
{
|
||||||
|
var btrManager = __instance.GetComponent<BTRManager>();
|
||||||
|
if (btrManager == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var botGame = Singleton<IBotGame>.Instance;
|
||||||
|
if (botGame == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
botGame.BotsController.BotSpawner.SpawnBotBTR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user