diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index a517c6169c..c9220ae5b4 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -322,6 +322,27 @@ public sealed partial class GunSystem : SharedGunSystem Audio.PlayPredicted(gun.SoundEmpty, gunUid, user); } + if (IsClientSide(ent!.Value)) + Del(ent.Value); + + break; + case HitScanCartridgeAmmoComponent hitScanCartridge: + if (!hitScanCartridge.Spent) + { + SetHitscanCartridgeSpent(ent!.Value, hitScanCartridge, true); + MuzzleFlash(gunUid, hitScanCartridge, worldAngle, user); + Audio.PlayPredicted(gun.SoundGunshotModified, gunUid, user); + Recoil(user, direction, gun.CameraRecoilScalarModified); + // TODO: Can't predict entity deletions. + //if (cartridge.DeleteOnSpawn) + // Del(cartridge.Owner); + } + else + { + userImpulse = false; + Audio.PlayPredicted(gun.SoundEmpty, gunUid, user); + } + if (IsClientSide(ent!.Value)) Del(ent.Value); diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index 2f224c9e6a..5a41ac3dc1 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -139,50 +139,58 @@ public sealed partial class GunSystem : SharedGunSystem Dirty(ent!.Value, cartridge); break; case HitScanCartridgeAmmoComponent hitScanCartridge: - var hitscanProto = ProtoManager.Index(hitScanCartridge.Prototype); - if (hitscanProto.ShootModifier == ShootModifier.Split) + if (!hitScanCartridge.Spent) { - var perpendicularOffset = new Vector2(-mapDirection.Y, mapDirection.X).Normalized(); - - for (var i = 0; i < hitscanProto.SplitCount; i++) + var hitscanProto = ProtoManager.Index(hitScanCartridge.Prototype); + if (hitscanProto.ShootModifier == ShootModifier.Split) { - var offset = hitscanProto.SplitOffset * (i - (hitscanProto.SplitCount - 1) / 2.0f); + var perpendicularOffset = new Vector2(-mapDirection.Y, mapDirection.X).Normalized(); - var startCoordinates = fromCoordinates.Offset(perpendicularOffset * offset); - var startMapCoordinates = fromMap.Offset(perpendicularOffset * offset); + for (var i = 0; i < hitscanProto.SplitCount; i++) + { + var offset = hitscanProto.SplitOffset * (i - (hitscanProto.SplitCount - 1) / 2.0f); - HitscanShoot(startMapCoordinates, startCoordinates, mapDirection, hitscanProto, gunUid, user, gun); + var startCoordinates = fromCoordinates.Offset(perpendicularOffset * offset); + var startMapCoordinates = fromMap.Offset(perpendicularOffset * offset); + + HitscanShoot(startMapCoordinates, startCoordinates, mapDirection, hitscanProto, gunUid, user, gun); + } } - } - else if (hitscanProto.ShootModifier == ShootModifier.Spread) - { - var spreadEvent = new GunGetAmmoSpreadEvent(hitscanProto.SpreadAngle); - RaiseLocalEvent(gunUid, ref spreadEvent); - - var angles = LinearSpread(mapAngle - spreadEvent.Spread / 2, - mapAngle + spreadEvent.Spread / 2, hitscanProto.SpreadCount); - - HitscanShoot(fromMap, fromCoordinates, angles[0].ToVec(), hitscanProto, gunUid, user, gun, ent!.Value); - - for (var i = 1; i < hitscanProto.SpreadCount; i++) + else if (hitscanProto.ShootModifier == ShootModifier.Spread) { - HitscanShoot(fromMap, fromCoordinates, angles[i].ToVec(), hitscanProto, gunUid, user, gun, ent.Value); + var spreadEvent = new GunGetAmmoSpreadEvent(hitscanProto.SpreadAngle); + RaiseLocalEvent(gunUid, ref spreadEvent); + + var angles = LinearSpread(mapAngle - spreadEvent.Spread / 2, + mapAngle + spreadEvent.Spread / 2, hitscanProto.SpreadCount); + + HitscanShoot(fromMap, fromCoordinates, angles[0].ToVec(), hitscanProto, gunUid, user, gun, ent!.Value); + + for (var i = 1; i < hitscanProto.SpreadCount; i++) + { + HitscanShoot(fromMap, fromCoordinates, angles[i].ToVec(), hitscanProto, gunUid, user, gun, ent.Value); + } } + else + { + HitscanShoot(fromMap, fromCoordinates, mapDirection, hitscanProto, gunUid, user, gun, ent!.Value); + } + + SetHitscanCartridgeSpent(ent!.Value, hitScanCartridge, true); + + if (hitScanCartridge.DeleteOnSpawn) + Del(ent.Value); } else { - HitscanShoot(fromMap, fromCoordinates, mapDirection, hitscanProto, gunUid, user, gun, ent!.Value); + userImpulse = false; + Audio.PlayPredicted(gun.SoundEmpty, gunUid, user); } - SetHitscanCartridgeSpent(ent!.Value, hitScanCartridge, true); - - if (hitScanCartridge.DeleteOnSpawn) - Del(ent.Value); - if (!hitScanCartridge.DeleteOnSpawn && !Containers.IsEntityInContainer(ent!.Value)) EjectCartridge(ent.Value, angle); - Dirty(ent.Value, hitScanCartridge); + Dirty(ent!.Value, hitScanCartridge); break; // Ammo shoots itself case AmmoComponent newAmmo: diff --git a/Resources/Changelog/ChangelogSunrise.yml b/Resources/Changelog/ChangelogSunrise.yml index 7fb49ff0e4..9d2f51b052 100644 --- a/Resources/Changelog/ChangelogSunrise.yml +++ b/Resources/Changelog/ChangelogSunrise.yml @@ -7453,3 +7453,19 @@ type: Tweak id: 522 time: '2024-12-07T04:40:14.625306+00:00' +- author: VigersRay + changes: + - message: "\u041F\u0430\u0442\u0440\u043E\u043D\u044B \u0431\u043E\u043B\u044C\u0448\ + \u0435 \u043D\u0435 \u043C\u043D\u043E\u0433\u043E\u0440\u0430\u0437\u043E\u0432\ + \u044B\u0435 \u0438 \u0440\u0430\u0441\u0445\u043E\u0434\u0443\u044E\u0442\u0441\ + \u044F \u043F\u043E\u0441\u043B\u0435 \u0432\u044B\u0441\u0442\u0440\u0435\u043B\ + \u0430." + type: Fix + - message: "\u0423 \u043D\u0435\u043B\u0435\u0442\u0430\u043B\u044C\u043D\u043E\u0433\ + \u043E \u043F\u0438\u0441\u0442\u043E\u043B\u0435\u0442\u0430 \u0421\u0411 \u0442\ + \u0435\u043F\u0435\u0440\u044C \u0440\u0435\u0437\u0438\u043D\u043E\u0432\u0430\ + \u044F \u043F\u0443\u043B\u044F \u0432 \u0437\u0430\u0442\u0432\u043E\u0440\u0435\ + ." + type: Fix + id: 523 + time: '2024-12-07T05:22:58.069374+00:00'