From 8f8c56d52817319b2edef382bf904b766d5896a4 Mon Sep 17 00:00:00 2001 From: Nympfonic Date: Sun, 16 Jun 2024 08:35:24 +0000 Subject: [PATCH] Fixed BTR doing a wheelie in Woods (!139) I've done testing to ensure the player can't phase through the BTR as well. Have not tested anything else besides that. Reviewed-on: https://dev.sp-tarkov.com/SPT/Modules/pulls/139 Co-authored-by: Nympfonic Co-committed-by: Nympfonic --- project/SPT.Custom/BTR/BTRManager.cs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/project/SPT.Custom/BTR/BTRManager.cs b/project/SPT.Custom/BTR/BTRManager.cs index 6d13a3c..d8eaea3 100644 --- a/project/SPT.Custom/BTR/BTRManager.cs +++ b/project/SPT.Custom/BTR/BTRManager.cs @@ -290,7 +290,7 @@ namespace SPT.Custom.BTR private IEnumerator CoverFireTimer(float time) { - yield return new WaitForSecondsRealtime(time); + yield return new WaitForSeconds(time); botEventHandler.StopTraderServiceBtrSupport(); } @@ -314,7 +314,9 @@ namespace SPT.Custom.BTR { var player = gameWorld.MainPlayer; - BTRSide btrSide = player.BtrInteractionSide != null ? player.BtrInteractionSide : lastInteractedBtrSide; + BTRSide btrSide = player.BtrInteractionSide != null + ? player.BtrInteractionSide + : lastInteractedBtrSide; byte sideId = btrClientSide.GetSideId(btrSide); switch (sideId) { @@ -373,6 +375,19 @@ namespace SPT.Custom.BTR } btrServerSide.turnCheckerObject.GetComponent().enabled = false; // Disables the red debug sphere + + // For some reason the client BTR collider is disabled but the server collider is enabled. + // Initially we assumed there was a reason for this so it was left as is. + // Turns out disabling the server collider in favour of the client collider fixes the "BTR doing a wheelie" bug, + // while preventing the player from walking through the BTR. + const string exteriorColliderName = "BTR_82_exterior_COLLIDER"; + var serverExteriorCollider = btrServerSide.GetComponentsInChildren(true) + .First(x => x.gameObject.name == exteriorColliderName); + var clientExteriorCollider = btrClientSide.GetComponentsInChildren(true) + .First(x => x.gameObject.name == exteriorColliderName); + + serverExteriorCollider.gameObject.SetActive(false); + clientExteriorCollider.gameObject.SetActive(true); } private void UpdateTarget() @@ -430,7 +445,7 @@ namespace SPT.Custom.BTR { isShooting = true; - yield return new WaitForSecondsRealtime(machineGunAimDelay); + yield return new WaitForSeconds(machineGunAimDelay); if (currentTarget?.Person == null || currentTarget?.IsVisible == false || !btrBotShooter.BotBtrData.CanShoot()) { isShooting = false; @@ -457,11 +472,11 @@ namespace SPT.Custom.BTR firearmController.PlayWeaponSound(weaponSoundPlayer, btrMachineGunAmmo, machineGunMuzzle.position, aimDirection, false); burstCount--; - yield return new WaitForSecondsRealtime(0.092308f); // 650 RPM + yield return new WaitForSeconds(0.092308f); // 650 RPM } float waitTime = Random.Range(machineGunRecoveryTime.x, machineGunRecoveryTime.y); - yield return new WaitForSecondsRealtime(waitTime); + yield return new WaitForSeconds(waitTime); isShooting = false; }