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:
Arendian
2023-07-29 23:07:31 +02:00
committed by GitHub
parent 1fe9a071b1
commit 2c5f202dca
3 changed files with 14 additions and 1 deletions

View File

@@ -377,6 +377,7 @@ public abstract partial class SharedGunSystem : EntitySystem
/// </summary>
protected void EjectCartridge(
EntityUid entity,
Angle? angle = null,
bool playSound = true)
{
// TODO: Sound limit version.
@@ -389,6 +390,13 @@ public abstract partial class SharedGunSystem : EntitySystem
TransformSystem.SetLocalRotation(xform, Random.NextAngle());
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))
{
Audio.PlayPvs(cartridge.EjectSound, entity, AudioParams.Default.WithVariation(0.05f).WithVolume(-1f));