Skip to content

Commit

Permalink
Fix Camora / Cylinder bullet use sync
Browse files Browse the repository at this point in the history
  • Loading branch information
paulov-t committed May 9, 2024
1 parent 96f8bf6 commit 5ac7d06
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Source/Coop/NetworkPacket/Player/Weapons/InitiateShotPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

using BepInEx.Logging;
using ChartAndGraph;
using Comfort.Common;
using EFT;
using EFT.InventoryLogic;
Expand All @@ -15,6 +16,7 @@
using System.Net.Sockets;
using UnityEngine;
using UnityEngine.UIElements;
using static EFT.UI.CharacterSelectionStartScreen;
using static StayInTarkov.Networking.SITSerialization;

namespace StayInTarkov.Coop.NetworkPacket.Player.Weapons
Expand Down Expand Up @@ -161,6 +163,7 @@ protected override void Process(CoopPlayerClient client)

if (firearmControllerClient.Weapon.GetCurrentMagazine() is CylinderMagazineClass cylindermag)
{
cylindermag.Camoras[cylindermag.CurrentCamoraIndex].RemoveItem();
cylindermag.IncrementCamoraIndex();
firearmControllerClient.FirearmsAnimator.SetCamoraIndex(cylindermag.CurrentCamoraIndex);
}
Expand All @@ -171,6 +174,9 @@ protected override void Process(CoopPlayerClient client)
firearmControllerClient.LightAndSoundShot(ShotPosition, ShotDirection, ammoToFire.AmmoTemplate);
}




break;
default:
break;
Expand All @@ -190,26 +196,32 @@ private IEnumerator DisableBoltActionAnim(SITFirearmControllerClient client)

private void GetBulletToFire(CoopPlayerClient client, Weapon weapon_0, out BulletClass ammoToFire)
{
var pic = ItemFinder.GetPlayerInventoryController(client);

if (weapon_0.GetCurrentMagazine() is CylinderMagazineClass cylindermag)
{
ammoToFire = cylindermag.GetFirstAmmo(singleFireMode: false);
// Is Used?
ammoToFire.IsUsed = true;
//ammoToFire = cylindermag.GetFirstAmmo(singleFireMode: false);

Logger.LogDebug($"Used CylinderMagazineClass first bullet {ammoToFire}");
ammoToFire = cylindermag.Cartridges.Count > 0
? (BulletClass)cylindermag.Cartridges.PopToNowhere(pic).Value.Item
: cylindermag.Camoras.Length > 0 ? (BulletClass)cylindermag.Camoras[cylindermag.CurrentCamoraIndex].ContainedItem
: null;

Logger.LogDebug($"Used CylinderMagazineClass {ammoToFire}");

return;
}

var pic = ItemFinder.GetPlayerInventoryController(client);

// Find the Ammo in the Chamber
Slot[] chambers = weapon_0.Chambers;
ammoToFire = (weapon_0.HasChambers ? chambers[0] : null)?.ContainedItem as BulletClass;
// ammoToFire
if (ammoToFire != null)
{
#if DEBUG
Logger.LogDebug($"Used {ammoToFire} in Chamber");
#endif
weapon_0.Chambers[0].RemoveItem().OrElse(elseValue: false);
return;
}
Expand All @@ -229,9 +241,10 @@ private void GetBulletToFire(CoopPlayerClient client, Weapon weapon_0, out Bulle
//}
//else
//{
ammoToFire = (BulletClass)currentMagazine.Cartridges.PopToNowhere(pic).Value.Item;

Logger.LogDebug($"Popped {ammoToFire} to nowhere");
ammoToFire = (BulletClass)currentMagazine.Cartridges.PopToNowhere(pic).Value.Item;
#if DEBUG
Logger.LogDebug($"Popped {ammoToFire} to nowhere");
#endif
//}


Expand Down

0 comments on commit 5ac7d06

Please sign in to comment.