mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Fix error when BTR kills enemy (!82)
Fixes an NRE when the BTR kills an enemy while using cover fire service Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: SPT-AKI/Modules#82 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
c8507fb600
commit
44e9f44f70
@ -450,7 +450,7 @@ namespace Aki.Custom.BTR
|
|||||||
isShooting = true;
|
isShooting = true;
|
||||||
|
|
||||||
yield return new WaitForSecondsRealtime(machineGunAimDelay);
|
yield return new WaitForSecondsRealtime(machineGunAimDelay);
|
||||||
if (!currentTarget.IsVisible || !btrBotShooter.BotBtrData.CanShoot())
|
if (currentTarget?.Person == null || currentTarget?.IsVisible == false || !btrBotShooter.BotBtrData.CanShoot())
|
||||||
{
|
{
|
||||||
isShooting = false;
|
isShooting = false;
|
||||||
yield break;
|
yield break;
|
||||||
@ -462,9 +462,14 @@ namespace Aki.Custom.BTR
|
|||||||
int burstMin = Mathf.FloorToInt(machineGunBurstCount.x);
|
int burstMin = Mathf.FloorToInt(machineGunBurstCount.x);
|
||||||
int burstMax = Mathf.FloorToInt(machineGunBurstCount.y);
|
int burstMax = Mathf.FloorToInt(machineGunBurstCount.y);
|
||||||
int burstCount = Random.Range(burstMin, burstMax + 1);
|
int burstCount = Random.Range(burstMin, burstMax + 1);
|
||||||
|
Vector3 targetHeadPos = currentTarget.Person.PlayerBones.Head.position;
|
||||||
while (burstCount > 0)
|
while (burstCount > 0)
|
||||||
{
|
{
|
||||||
Vector3 targetHeadPos = currentTarget.Person.PlayerBones.Head.position;
|
// Only update shooting position if the target isn't null
|
||||||
|
if (currentTarget?.Person != null)
|
||||||
|
{
|
||||||
|
targetHeadPos = currentTarget.Person.PlayerBones.Head.position;
|
||||||
|
}
|
||||||
Vector3 aimDirection = Vector3.Normalize(targetHeadPos - machineGunMuzzle.position);
|
Vector3 aimDirection = Vector3.Normalize(targetHeadPos - machineGunMuzzle.position);
|
||||||
ballisticCalculator.Shoot(btrMachineGunAmmo, machineGunMuzzle.position, aimDirection, btrBotShooter.ProfileId, btrMachineGunWeapon, 1f, 0);
|
ballisticCalculator.Shoot(btrMachineGunAmmo, machineGunMuzzle.position, aimDirection, btrBotShooter.ProfileId, btrMachineGunWeapon, 1f, 0);
|
||||||
firearmController.method_54(weaponSoundPlayer, btrMachineGunAmmo, machineGunMuzzle.position, aimDirection, false);
|
firearmController.method_54(weaponSoundPlayer, btrMachineGunAmmo, machineGunMuzzle.position, aimDirection, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user