Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port] Случайные выстрелы при падении оружия #147

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()));
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Weapons/Ranged/Components/GunComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ public sealed partial class GunComponent : Component
/// </summary>
[DataField]
public Vector2 DefaultDirection = new Vector2(0, -1);

/// <summary>
/// Corvax-Next. The percentage chance of a given gun to accidentally discharge if violently thrown into a wall or person
/// </summary>
[DataField]
public float FireOnDropChance = 0.1f;
}

[Flags]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/kinetic_accel.ogg
fireOnDropChance: 1 # Corvax-Next-FireOnDrop
- type: AmmoCounter
- type: Appearance
- type: GenericVisualizer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/laser.ogg
fireOnDropChance: 0.15 # Corvax-Next-FireOnDrop
- type: Battery
maxCharge: 1000
startingCharge: 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- FullAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/pistol.ogg
fireOnDropChance: 0.3 # Corvax-Next-FireOnDrop
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/pistol_cock.ogg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/revolver.ogg
fireOnDropChance: 0.6 # Corvax-Next-FireOnDrop
- type: UseDelay
delay: 0.66
- type: ContainerContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- FullAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/batrifle.ogg
fireOnDropChance: 0.5 # Corvax-Next-FireOnDrop
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/smg.ogg
defaultDirection: 1, 0
fireOnDropChance: 0.3 # Corvax-Next-FireOnDrop
- type: ChamberMagazineAmmoProvider
soundRack:
path: /Audio/Weapons/Guns/Cock/smg_cock.ogg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
path: /Audio/Weapons/Guns/Gunshots/shotgun.ogg
soundEmpty:
path: /Audio/Weapons/Guns/Empty/empty.ogg
fireOnDropChance: 0.3 # Corvax-Next-FireOnDrop
- type: BallisticAmmoProvider
whitelist:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- SemiAuto
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/sniper.ogg
fireOnDropChance: 0.9 # Corvax-Next-FireOnDrop
- type: BallisticAmmoProvider
capacity: 10
proto: CartridgeLightRifle
Expand Down
Loading