Give kammerer tighter spread so it's not a complete downgrade to the enforcer (#37616)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user