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

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: SPT/Modules#139
Co-authored-by: Nympfonic <arys.steam@gmail.com>
Co-committed-by: Nympfonic <arys.steam@gmail.com>
This commit is contained in:
Nympfonic 2024-06-16 08:35:24 +00:00 committed by chomp
parent 5b5d498102
commit 8f8c56d528

View File

@ -290,7 +290,7 @@ namespace SPT.Custom.BTR
private IEnumerator CoverFireTimer(float time) private IEnumerator CoverFireTimer(float time)
{ {
yield return new WaitForSecondsRealtime(time); yield return new WaitForSeconds(time);
botEventHandler.StopTraderServiceBtrSupport(); botEventHandler.StopTraderServiceBtrSupport();
} }
@ -314,7 +314,9 @@ namespace SPT.Custom.BTR
{ {
var player = gameWorld.MainPlayer; 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); byte sideId = btrClientSide.GetSideId(btrSide);
switch (sideId) switch (sideId)
{ {
@ -373,6 +375,19 @@ namespace SPT.Custom.BTR
} }
btrServerSide.turnCheckerObject.GetComponent<Renderer>().enabled = false; // Disables the red debug sphere btrServerSide.turnCheckerObject.GetComponent<Renderer>().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<Collider>(true)
.First(x => x.gameObject.name == exteriorColliderName);
var clientExteriorCollider = btrClientSide.GetComponentsInChildren<Collider>(true)
.First(x => x.gameObject.name == exteriorColliderName);
serverExteriorCollider.gameObject.SetActive(false);
clientExteriorCollider.gameObject.SetActive(true);
} }
private void UpdateTarget() private void UpdateTarget()
@ -430,7 +445,7 @@ namespace SPT.Custom.BTR
{ {
isShooting = true; isShooting = true;
yield return new WaitForSecondsRealtime(machineGunAimDelay); yield return new WaitForSeconds(machineGunAimDelay);
if (currentTarget?.Person == null || currentTarget?.IsVisible == false || !btrBotShooter.BotBtrData.CanShoot()) if (currentTarget?.Person == null || currentTarget?.IsVisible == false || !btrBotShooter.BotBtrData.CanShoot())
{ {
isShooting = false; isShooting = false;
@ -457,11 +472,11 @@ namespace SPT.Custom.BTR
firearmController.PlayWeaponSound(weaponSoundPlayer, btrMachineGunAmmo, machineGunMuzzle.position, aimDirection, false); firearmController.PlayWeaponSound(weaponSoundPlayer, btrMachineGunAmmo, machineGunMuzzle.position, aimDirection, false);
burstCount--; 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); float waitTime = Random.Range(machineGunRecoveryTime.x, machineGunRecoveryTime.y);
yield return new WaitForSecondsRealtime(waitTime); yield return new WaitForSeconds(waitTime);
isShooting = false; isShooting = false;
} }