]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Give kammerer tighter spread so it's not a complete downgrade to the enforcer (#37616)
authorSpeltIncorrectyl <66873282+SpeltIncorrectyl@users.noreply.github.com>
Mon, 19 May 2025 22:45:18 +0000 (23:45 +0100)
committerGitHub <noreply@github.com>
Mon, 19 May 2025 22:45:18 +0000 (15:45 -0700)
Content.Shared/Weapons/Ranged/Components/GunSpreadModifierComponent.cs [new file with mode: 0644]
Content.Shared/Weapons/Ranged/Systems/GunSpreadModifierSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/weapons/ranged/gun.ftl
Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml

diff --git a/Content.Shared/Weapons/Ranged/Components/GunSpreadModifierComponent.cs b/Content.Shared/Weapons/Ranged/Components/GunSpreadModifierComponent.cs
new file mode 100644 (file)
index 0000000..7f889f5
--- /dev/null
@@ -0,0 +1,16 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Weapons.Ranged.Components;
+
+/// <summary>
+/// This component modifies the spread of the gun it is attached to.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class GunSpreadModifierComponent: Component
+{
+    /// <summary>
+    /// A scalar value multiplied by the spread built into the ammo itself.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public float Spread = 1;
+}
diff --git a/Content.Shared/Weapons/Ranged/Systems/GunSpreadModifierSystem.cs b/Content.Shared/Weapons/Ranged/Systems/GunSpreadModifierSystem.cs
new file mode 100644 (file)
index 0000000..84d8dd2
--- /dev/null
@@ -0,0 +1,30 @@
+using Content.Shared.Examine;
+using Content.Shared.Weapons.Ranged.Components;
+using Content.Shared.Weapons.Ranged.Events;
+
+namespace Content.Shared.Weapons.Ranged.Systems;
+
+
+public sealed class GunSpreadModifierSystem: EntitySystem
+{
+    public override void Initialize()
+    {
+        base.Initialize();
+        SubscribeLocalEvent<GunSpreadModifierComponent, GunGetAmmoSpreadEvent>(OnGunGetAmmoSpread);
+        SubscribeLocalEvent<GunSpreadModifierComponent, ExaminedEvent>(OnExamine);
+    }
+
+    private void OnGunGetAmmoSpread(EntityUid uid, GunSpreadModifierComponent comp, ref GunGetAmmoSpreadEvent args)
+    {
+        args.Spread *= comp.Spread;
+    }
+
+    private void OnExamine(EntityUid uid, GunSpreadModifierComponent comp, ExaminedEvent args)
+    {
+        var percentage = Math.Round(comp.Spread * 100);
+        var loc = percentage < 100 ? "examine-gun-spread-modifier-reduction" : "examine-gun-spread-modifier-increase";
+        percentage = percentage < 100 ? 100 - percentage : percentage - 100;
+        var msg = Loc.GetString(loc, ("percentage", percentage));
+        args.PushMarkup(msg);
+    }
+}
index 10bc9e6c78f02d40bc0d6003b465b3d650d0c1f7..18e01e31c83d383f1344f03d0e4e8f135f55321d 100644 (file)
@@ -50,3 +50,7 @@ gun-revolver-insert = Inserted
 gun-revolver-spin = Spin revolver
 gun-revolver-spun = Spun
 gun-speedloader-empty = Speedloader empty
+
+# GunSpreadModifier
+examine-gun-spread-modifier-reduction = The spread has been reduced by [color=yellow]{$percentage}%[/color].
+examine-gun-spread-modifier-increase = The spread has been increased by [color=yellow]{$percentage}%[/color].
index 4cbdb99f695bdc5c4be14254a76bd18165b53f27..b2e8d0a14b10ecd523c6dba08735a4ea8cc3a90a 100644 (file)
   - type: GunRequiresWield #remove when inaccuracy on spreads is fixed
   - type: Gun
     fireRate: 1
+  - type: GunSpreadModifier
+    spread: 0.6
   - type: Tag
     tags:
     - WeaponShotgunKammerer