Eject casings some distance from the gun (#18081)
Makes bullet casings launch a bit away from you when shooting a gun. Cycling still drops it at your feet. --------- Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
This commit is contained in:
@@ -171,7 +171,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
|
|
||||||
// Something like ballistic might want to leave it in the container still
|
// Something like ballistic might want to leave it in the container still
|
||||||
if (!cartridge.DeleteOnSpawn && !Containers.IsEntityInContainer(ent!.Value))
|
if (!cartridge.DeleteOnSpawn && !Containers.IsEntityInContainer(ent!.Value))
|
||||||
EjectCartridge(ent.Value);
|
EjectCartridge(ent.Value, angle);
|
||||||
|
|
||||||
Dirty(cartridge);
|
Dirty(cartridge);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -377,6 +377,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected void EjectCartridge(
|
protected void EjectCartridge(
|
||||||
EntityUid entity,
|
EntityUid entity,
|
||||||
|
Angle? angle = null,
|
||||||
bool playSound = true)
|
bool playSound = true)
|
||||||
{
|
{
|
||||||
// TODO: Sound limit version.
|
// TODO: Sound limit version.
|
||||||
@@ -389,6 +390,13 @@ public abstract partial class SharedGunSystem : EntitySystem
|
|||||||
TransformSystem.SetLocalRotation(xform, Random.NextAngle());
|
TransformSystem.SetLocalRotation(xform, Random.NextAngle());
|
||||||
TransformSystem.SetCoordinates(entity, xform, coordinates);
|
TransformSystem.SetCoordinates(entity, xform, coordinates);
|
||||||
|
|
||||||
|
// decides direction the casing ejects and only when not cycling
|
||||||
|
if (angle != null)
|
||||||
|
{
|
||||||
|
Angle ejectAngle = angle.Value;
|
||||||
|
ejectAngle += 3.7f; // 212 degrees; casings should eject slightly to the right and behind of a gun
|
||||||
|
ThrowingSystem.TryThrow(entity, ejectAngle.ToVec().Normalized() / 100, 5f);
|
||||||
|
}
|
||||||
if (playSound && TryComp<CartridgeAmmoComponent>(entity, out var cartridge))
|
if (playSound && TryComp<CartridgeAmmoComponent>(entity, out var cartridge))
|
||||||
{
|
{
|
||||||
Audio.PlayPvs(cartridge.EjectSound, entity, AudioParams.Default.WithVariation(0.05f).WithVolume(-1f));
|
Audio.PlayPvs(cartridge.EjectSound, entity, AudioParams.Default.WithVariation(0.05f).WithVolume(-1f));
|
||||||
|
|||||||
@@ -22,3 +22,8 @@
|
|||||||
- type: Item
|
- type: Item
|
||||||
size: 1
|
size: 1
|
||||||
- type: SpaceGarbage
|
- type: SpaceGarbage
|
||||||
|
- type: EmitSoundOnLand
|
||||||
|
sound:
|
||||||
|
path: /Audio/Weapons/Guns/Casings/casing_fall_2.ogg
|
||||||
|
params:
|
||||||
|
volume: -1
|
||||||
|
|||||||
Reference in New Issue
Block a user