mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-19 06:28:40 +03:00
# Description Ports https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/pull/19 I have added a new stat for firearms, the "Reliability" stat, which is a number between 0 and 1. It's used as a percentage chance for the weapon to fire itself when violently thrown into anyone. This PR differs from the original one slightly in that to get it to actually work without crashing, I set the system to listen to an event that triggers whenever the gun collides with another entity, not necessarily just the floor. This is the same event responsible for the clown's cream pie system, or for glass shards embedding in an entity. # Changelog 🆑 - add: NanoTrasen has disabled the unneeded safeties on your guns- Make sure you're careful with them! - tweak: All Firearms now have a reliability stat, some are more reliable than others. The more reliable a weapon is, the less likely it is to accidentally discharge when yeeted.
28 lines
832 B
C#
28 lines
832 B
C#
using Content.Shared.Throwing;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
using Content.Shared.Weapons.Ranged.Systems;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Weapons.Ranged.Systems;
|
|
|
|
public sealed class FireOnDropSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedGunSystem _gun = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<GunComponent, ThrowDoHitEvent>(HandleLand);
|
|
}
|
|
|
|
|
|
private void HandleLand(EntityUid uid, GunComponent component, ref ThrowDoHitEvent args)
|
|
{
|
|
if (_random.Prob(component.FireOnDropChance))
|
|
_gun.AttemptShoot(uid, uid, component, Transform(uid).Coordinates.Offset(Transform(uid).LocalRotation.ToVec()));
|
|
}
|
|
}
|