]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make flare gun explode, damage and stun the player when used with the wrong ammo...
authorMendaxxDev <153332064+MendaxxDev@users.noreply.github.com>
Fri, 15 Dec 2023 09:57:59 +0000 (10:57 +0100)
committerGitHub <noreply@github.com>
Fri, 15 Dec 2023 09:57:59 +0000 (02:57 -0700)
* Flare gun can now only be loaded with actual flares

* Make flare gun loadable with other shells, but destroy it and damage and stun the user when used

* tweak

* Logic fix + QOL add-ons

* damageOnWrongAmmo in gun component

* cleanup

Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Content.Shared/Weapons/Ranged/Components/GunComponent.cs
Resources/Locale/en-US/weapons/ranged/gun.ftl
Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml
Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/shotgun.yml
Resources/Prototypes/Entities/Objects/Weapons/Guns/flare_gun.yml
Resources/Prototypes/tags.yml

index bbac7acd125d7c39932192fe3505136d03980b94..5f8ab0ecb6e2c2ba1b040cae08d0767faf15d49e 100644 (file)
@@ -10,6 +10,7 @@ using Content.Shared.Damage;
 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;
@@ -132,6 +133,27 @@ public sealed partial class GunSystem : SharedGunSystem
                 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,
index fb52870df8e694f79723597c19f2263de00f53df..350dd85d6972d8794cb6b9fc3fcad3e8412065b4 100644 (file)
@@ -1,7 +1,11 @@
+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;
 
@@ -110,6 +114,18 @@ public partial class GunComponent : Component
     [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>
index fe60f3eed1d9d77526b8cb17868c5cd8e9d25543..3fbf5f77e767330ca8d35057b96dd5221003383a 100644 (file)
@@ -6,6 +6,7 @@ gun-selected-mode = Selected {$mode}
 gun-disabled = You can't use guns!
 gun-clumsy = The gun blows up in your face!
 gun-set-fire-mode = Set to {$mode}
+gun-component-wrong-ammo = Wrong ammo!
 
 # SelectiveFire
 gun-SemiAuto = semi-auto
index 21780fefb61d0cfef3b7e11630878ef653218c3c..92a88111f519a7f856911cf595c8a59a11c38dc4 100644 (file)
     spread: 45 #deadly if you can get up close... otherwise, good luck doing any kind of real damage
     proto: PelletShotgunImprovised
   - type: SpentAmmoVisuals
-    state: "improvised"
\ No newline at end of file
+    state: "improvised"
index 887295b4b1cd500e028ca42aacf8b63e1b7a9b25..5f19ac03d0beafbc41feb1758656549b9a8a1e4b 100644 (file)
@@ -75,7 +75,7 @@
   id: PelletShotgunImprovised
   name: improvised pellet
   noSpawn: true
-  parent: BaseBullet 
+  parent: BaseBullet
   components:
   - type: Sprite
     sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
           - ItemMask
         restitution: 0.3
         friction: 0.2
+  - type: Tag
+    tags:
+      - PelletShotgunFlare
   - type: Sprite
     sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
     state: buckshot-flare
index cfcc0a01cd1f26d486af1c3a1e6287a723e3b296..810a36105bd0639b7795cef057b430e33a194092 100644 (file)
     selectedMode: SemiAuto
     availableModes:
       - SemiAuto
+    compatibleAmmo:
+      - PelletShotgunFlare
     soundGunshot:
       path: /Audio/Weapons/Guns/Gunshots/flaregun.ogg
+    damageOnWrongAmmo:
+      types:
+        Blunt: 6.0
   - type: BallisticAmmoProvider
     whitelist:
       tags:
index dfdaa8578904e5078b37a41af6bb34703f5fad32..4546c4ac486b3c89a3ea9b9aff42529db636da30 100644 (file)
 - type: Tag
   id: ShellShotgun
 
+- type: Tag
+  id: PelletShotgunFlare
+
 - type: Tag
   id: Shiv