Skip to content

Commit

Permalink
[Port] Случайные выстрелы при падении оружия (#147)
Browse files Browse the repository at this point in the history
* FireOnDrop

* whoopsy
  • Loading branch information
Vonsant authored Dec 10, 2024
1 parent 504cea1 commit e3f7bce
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 0 deletions.
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

0 comments on commit e3f7bce

Please sign in to comment.