using Content.Shared.Damage.Systems;
using Content.Shared.Database;
using Content.Shared.Effects;
+using Content.Shared.FixedPoint;
using Content.Shared.Interaction.Components;
using Content.Shared.Projectiles;
using Content.Shared.Weapons.Melee;
case CartridgeAmmoComponent cartridge:
if (!cartridge.Spent)
{
+ if (gun.CompatibleAmmo != null &&
+ !gun.CompatibleAmmo.Exists(ammoAllowed => ammoAllowed.Equals(cartridge.Prototype))
+ && user != null)
+ {
+ if (gun.DamageOnWrongAmmo != null)
+ Damageable.TryChangeDamage(user, gun.DamageOnWrongAmmo, origin: user);
+ _stun.TryParalyze(user.Value, TimeSpan.FromSeconds(3f), true);
+
+ Audio.PlayPvs(new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/bang.ogg"), gunUid);
+
+ PopupSystem.PopupEntity(Loc.GetString("gun-component-wrong-ammo"), user.Value);
+ _adminLogger.Add(LogType.EntityDelete, LogImpact.Medium, $"Shot wrong ammo by {ToPrettyString(user.Value)} deleted {ToPrettyString(gunUid)}");
+ userImpulse = false;
+
+ SetCartridgeSpent(ent!.Value, cartridge, true);
+ MuzzleFlash(gunUid, cartridge, user);
+ Del(gunUid);
+ if (cartridge.DeleteOnSpawn)
+ Del(ent.Value);
+ return;
+ }
if (cartridge.Count > 1)
{
var angles = LinearSpread(mapAngle - cartridge.Spread / 2,
+using Content.Shared.Damage;
+using Content.Shared.Tag;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
+using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Weapons.Ranged.Components;
[ViewVariables(VVAccess.ReadWrite), DataField("resetOnHandSelected")]
public bool ResetOnHandSelected = true;
+ /// <summary>
+ /// Type of ammo the gun can work with
+ /// </summary>
+ [ViewVariables(VVAccess.ReadWrite), DataField("compatibleAmmo")]
+ public List<ProtoId<TagPrototype>>? CompatibleAmmo;
+
+ /// <summary>
+ /// Damage the gun deals when used with wrong ammo
+ /// </summary>
+ [ViewVariables(VVAccess.ReadWrite), DataField("damageOnWrongAmmo")]
+ public DamageSpecifier? DamageOnWrongAmmo = null;
+
/// <summary>
/// How fast the projectile moves.
/// </summary>