-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Randomly Fire Dropped Weapons (#471)
# Description Ports Simple-Station/Parkstation-Friendly-Chainsaw#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 :cl: - 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.
- Loading branch information
Showing
10 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters